
#include "damage.h"

#ifndef PandaWave_RESOURCES
#include "RevengeResources.h"
#endif

#include "RevengeApp.h"
#include <XMessages.h>
#include "tagpick.h"
#include <assert.h>
#include <XPopup.h>
#include <XWindow.h>


// ==============================  BYTE SWAPPING DATA  ========================================
// Actually, the Byte Swapping occurs in the tag.  We shouldn't do it here.
static byte_swap_code damage_definition_byte_swapping_data[]=
{
	_end_bs_array
};



// ==============================  EDIT WINDOW  ========================================
void edit_damage( tag_entry* e )
{
	TdamageEditForm* form = new TdamageEditForm( e );
	form->AttachWindow( 2003 );
}


// ==============================  READ TAG DATA  ========================================
bool read_damage_definition( damage_definition* def, tag_entry* e )
{
	return load_tag_data_into_struct( "damage", e, def, SIZEOF_STRUCT_DAMAGE_DEFINITION, 1, damage_definition_byte_swapping_data);
}


// ==============================  SAVE TAG DATA  ========================================
bool save_damage_definition( damage_definition* def, tag_entry* e )
{
	return save_tag_data_from_struct( "damage", e, def, SIZEOF_STRUCT_DAMAGE_DEFINITION, 1, damage_definition_byte_swapping_data);
}


// ==============================  READ TAG DATA (WITH ID) ========================================
bool read_damage_definition( damage_definition* def, tag id )
{
	tag_entry* e;
	
	assert( def );
	
	e = get_entry( 'damage', id );
	if( 0 == e ) {
		return FALSE;
	}
	
	return read_damage_definition( def, e );	
}


// ==============================  SAVE TAG DATA (WITH ID) ========================================
bool save_damage_definition( damage_definition* def, tag id )
{
	tag_entry* e;
	
	assert( def );
	
	e = get_entry( 'damage', id );
	if( 0 == e ) {
		return FALSE;
	}

	return save_damage_definition( def, e );
}


// ==============================  DISPATCH  ========================================
BEGINDISPATCH(TdamageEditForm,TTagEditForm)
	DISPATCHTABLE(KXGControlClick,TdamageEditForm::DoControlClick)
ENDDISPATCH


TdamageEditForm::TdamageEditForm( struct tag_entry *e ) : TTagEditForm( e )
{
}

// ==============================  INITIALIZE FORM =======================================
void TdamageEditForm::DoFormInitialize()
{
	TTagEditForm::DoFormInitialize();

}


// ==============================  INPUT HANDLING  ========================================
long TdamageEditForm::DoControlClick( long arg, void *ptr )
{
#ifdef __MWERKS__
	#pragma unused(ptr)
#endif
	return -1;
}

		
// ========================================  SAVE TO TAG  ==================================================
void TdamageEditForm::CommitToTag()
{
	GetValues();
	save_damage_definition( &def, fEntry );
}


// ========================================  RELOAD TAG  ==================================================
void TdamageEditForm::ReloadTag()
{
	read_damage_definition( &def, fEntry );
	SetValues();
}


// ========================================  TAG NEEDS UPDATING  ==================================================
bool TdamageEditForm::NeedCommit()
{
	GetValues();
	return tag_data_needs_update( "damage", fEntry, &def, SIZEOF_STRUCT_DAMAGE_DEFINITION, 1, damage_definition_byte_swapping_data);
}

		
// ========================================  SET INTERFACE VALUES  ==================================================
void TdamageEditForm::SetValues()
{

/*
	TYPE
	_damage_explosion,
	_damage_magical,
	_damage_hold,
	_damage_healing, // heals damage
	_damage_kinetic,
	_damage_steel_slashing,
	_damage_stoning, // turns to stone (and causes damage?)
	_damage_claws_slashing,
	_damage_explosive_electricity,
	_damage_fire,
	_damage_gas, // only damages monsters, can't cause hard death
	_damage_charm // turns monster to caster's team

	FLAGS
	_damage_proportional_to_velocity_flag
	_damage_area_of_effect_flag
	_damage_does_not_interrupt_events_flag
	_damage_is_long_range_flag
	_damage_can_cause_paralysis_flag
	_damage_can_stun_flag
	_damage_cannot_be_blocked_flag
	_damage_cannot_be_healed_flag
	_damage_does_not_effect_monsters_flag
	_damage_detonates_explosives_immediately_flag
	_damage_proportional_to_mana_flag
	_damage_can_destroy_large_object_flag
	_damage_instantaneous_flag
	_damage_cannot_hurt_owner_flag
	_damage_does_not_make_monsters_flinch_flag
	_damage_can_cause_confusion_flag

	DATA
	short type;
	word flags;
	short_fixed damage_lower_bound, damage_delta;
	short_world_distance radius_lower_bound, radius_delta;
	short_world_distance rate_of_expansion; // world units per tick
	short_fixed damage_to_velocity;
*/


}


// ========================================  GET INTERFACE VALUES  ==================================================
void TdamageEditForm::GetValues()
{
}

