Skip to content

Commit

Permalink
widget: Remove write-only RENDERED_BUTTON::Initialised and RENDERED_B…
Browse files Browse the repository at this point in the history
…UTTON::State, and related dead code.
  • Loading branch information
Cyp committed Mar 12, 2013
1 parent 1240e7c commit 2521e71
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 130 deletions.
4 changes: 0 additions & 4 deletions src/design.cpp
Expand Up @@ -800,7 +800,6 @@ static bool _intAddTemplateForm(DROID_TEMPLATE *psSelected)


/* Add the design templates form */ /* Add the design templates form */
IntListTabWidget *templList = new IntListTabWidget(templbaseForm); IntListTabWidget *templList = new IntListTabWidget(templbaseForm);
templList->id = IDDES_TEMPLFORM;
templList->setChildSize(DES_TABBUTWIDTH, DES_TABBUTHEIGHT); templList->setChildSize(DES_TABBUTWIDTH, DES_TABBUTHEIGHT);
templList->setChildSpacing(DES_TABBUTGAP, DES_TABBUTGAP); templList->setChildSpacing(DES_TABBUTGAP, DES_TABBUTGAP);
int templListWidth = OBJ_BUTWIDTH*2 + DES_TABBUTGAP; int templListWidth = OBJ_BUTWIDTH*2 + DES_TABBUTGAP;
Expand Down Expand Up @@ -2983,7 +2982,6 @@ void intRemoveDesign(void)


widgDelete(psWScreen, IDDES_POWERFORM); widgDelete(psWScreen, IDDES_POWERFORM);
widgDelete(psWScreen, IDDES_NAMEBOX); widgDelete(psWScreen, IDDES_NAMEBOX);
widgDelete(psWScreen, IDDES_TEMPLFORM);
widgDelete(psWScreen, IDDES_TEMPLBASE); widgDelete(psWScreen, IDDES_TEMPLBASE);
widgDelete(psWScreen, IDDES_RIGHTBASE); widgDelete(psWScreen, IDDES_RIGHTBASE);


Expand Down Expand Up @@ -3594,7 +3592,6 @@ void intProcessDesign(UDWORD id)
desSetupDesignTemplates(); desSetupDesignTemplates();


/* Now update the droid template form */ /* Now update the droid template form */
widgDelete(psWScreen, IDDES_TEMPLFORM);
widgDelete(psWScreen, IDDES_TEMPLBASE); widgDelete(psWScreen, IDDES_TEMPLBASE);
intAddTemplateForm(psTempl); intAddTemplateForm(psTempl);


Expand Down Expand Up @@ -4062,7 +4059,6 @@ static bool saveTemplate(void)
sstrcpy(psTempl->aName, aCurrName); sstrcpy(psTempl->aName, aCurrName);


/* Now update the droid template form */ /* Now update the droid template form */
widgDelete(psWScreen, IDDES_TEMPLFORM);
widgDelete(psWScreen, IDDES_TEMPLBASE); widgDelete(psWScreen, IDDES_TEMPLBASE);
intAddTemplateForm(psTempl); intAddTemplateForm(psTempl);


Expand Down
1 change: 0 additions & 1 deletion src/design.h
Expand Up @@ -27,7 +27,6 @@
/* Design screen ID's */ /* Design screen ID's */
#define IDDES_FORM 5000 // The base form for the design screen #define IDDES_FORM 5000 // The base form for the design screen
#define IDDES_STATSFORM 5001 // The design screen stats form #define IDDES_STATSFORM 5001 // The design screen stats form
#define IDDES_TEMPLFORM 5002 // The tabbed form of design templates
#define IDDES_SYSTEMFORM 5006 // The clickable form for the weapon/ecm/sensor #define IDDES_SYSTEMFORM 5006 // The clickable form for the weapon/ecm/sensor
#define IDDES_BODYFORM 5007 // The clickable form for the body #define IDDES_BODYFORM 5007 // The clickable form for the body
#define IDDES_PROPFORM 5008 // The clickable form for the propulsion #define IDDES_PROPFORM 5008 // The clickable form for the propulsion
Expand Down
14 changes: 0 additions & 14 deletions src/hci.cpp
Expand Up @@ -1270,20 +1270,6 @@ INT_RETVAL intRunWidgets(void)
quitting = true; quitting = true;
break; break;


// Process form tab clicks.
case IDOBJ_TABFORM: // If tab clicked on in object screen then refresh all rendered buttons.
RefreshObjectButtons();
RefreshTopicButtons();
break;

case IDSTAT_TABFORM: // If tab clicked on in stats screen then refresh all rendered buttons.
RefreshStatsButtons();
break;

case IDDES_TEMPLFORM: // If tab clicked on in design template screen then refresh all rendered buttons.
RefreshStatsButtons();
break;

/* Default case passes remaining IDs to appropriate function */ /* Default case passes remaining IDs to appropriate function */
default: default:
switch (intMode) switch (intMode)
Expand Down
83 changes: 7 additions & 76 deletions src/intdisplay.cpp
Expand Up @@ -669,8 +669,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED); Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED);
} }


Buffer->State = Form->state;

Object = NULL; Object = NULL;
Image = -1; Image = -1;
psObj = (BASE_OBJECT *)Buffer->Data; // Get the object associated with this widget. psObj = (BASE_OBJECT *)Buffer->Data; // Get the object associated with this widget.
Expand Down Expand Up @@ -698,7 +696,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
{ {
Object = Structure; Object = Structure;
IMDType = IMDTYPE_STRUCTURE; IMDType = IMDTYPE_STRUCTURE;
RENDERBUTTON_INITIALISED(Buffer);
} }
} }
else if (DroidGoingToBuild(Droid)) else if (DroidGoingToBuild(Droid))
Expand All @@ -708,7 +705,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
Object = (void *)Stats; Object = (void *)Stats;
Player = selectedPlayer; Player = selectedPlayer;
IMDType = IMDTYPE_STRUCTURESTAT; IMDType = IMDTYPE_STRUCTURESTAT;
RENDERBUTTON_INITIALISED(Buffer);
} }
else if (orderState(Droid, DORDER_DEMOLISH)) else if (orderState(Droid, DORDER_DEMOLISH))
{ {
Expand All @@ -717,7 +713,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
Object = (void *)Stats; Object = (void *)Stats;
Player = selectedPlayer; Player = selectedPlayer;
IMDType = IMDTYPE_STRUCTURESTAT; IMDType = IMDTYPE_STRUCTURESTAT;
RENDERBUTTON_INITIALISED(Buffer);
} }
else if (Droid->droidType == DROID_COMMAND) else if (Droid->droidType == DROID_COMMAND)
{ {
Expand All @@ -726,7 +721,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
{ {
Object = Structure; Object = Structure;
IMDType = IMDTYPE_STRUCTURE; IMDType = IMDTYPE_STRUCTURE;
RENDERBUTTON_INITIALISED(Buffer);
} }
} }
break; break;
Expand All @@ -742,7 +736,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
{ {
IMDType = IMDTYPE_DROIDTEMPLATE; IMDType = IMDTYPE_DROIDTEMPLATE;
Object = (void *)FactoryGetTemplate(StructureGetFactory(Structure)); Object = (void *)FactoryGetTemplate(StructureGetFactory(Structure));
RENDERBUTTON_INITIALISED(Buffer);
bOnHold = StructureIsOnHoldPending(Structure); bOnHold = StructureIsOnHoldPending(Structure);
} }


Expand Down Expand Up @@ -800,7 +793,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
IMDType = IMDTYPE_RESEARCH; IMDType = IMDTYPE_RESEARCH;
} }
} }
RENDERBUTTON_INITIALISED(Buffer);
} }
break; break;
default: default:
Expand All @@ -812,10 +804,6 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
ASSERT(false, "Invalid structure type"); ASSERT(false, "Invalid structure type");
} }
} }
else
{
RENDERBUTTON_INITIALISED(Buffer);
}


// Render the object into the button. // Render the object into the button.
if (Object) if (Object)
Expand Down Expand Up @@ -880,8 +868,6 @@ void intDisplayObjectButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED); Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED);
} }


Buffer->State = Form->state;

Object = NULL; Object = NULL;
psObj = (BASE_OBJECT *)Buffer->Data; // Get the object associated with this widget. psObj = (BASE_OBJECT *)Buffer->Data; // Get the object associated with this widget.


Expand Down Expand Up @@ -920,8 +906,6 @@ void intDisplayObjectButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
RenderBlankToButton(Buffer, Down, BTMBUTTON); RenderBlankToButton(Buffer, Down, BTMBUTTON);
} }


RENDERBUTTON_INITIALISED(Buffer);

if (Hilight) if (Hilight)
{ {


Expand Down Expand Up @@ -952,8 +936,6 @@ void intDisplayStatsButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED); Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED);
} }


Buffer->State = Form->state;

Object = NULL; Object = NULL;
Image = -1; Image = -1;


Expand Down Expand Up @@ -1076,11 +1058,8 @@ void intDisplayStatsButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
RenderBlankToButton(Buffer, Down, TOPBUTTON); RenderBlankToButton(Buffer, Down, TOPBUTTON);
} }


RENDERBUTTON_INITIALISED(Buffer);

if (Hilight) if (Hilight)
{ {

iV_DrawImage(IntImages, IMAGE_BUT_HILITE, xOffset + Form->x(), yOffset + Form->y()); iV_DrawImage(IntImages, IMAGE_BUT_HILITE, xOffset + Form->x(), yOffset + Form->y());
} }
} }
Expand Down Expand Up @@ -1584,47 +1563,6 @@ void intInitialiseGraphics(void)
imageInitBitmaps(); imageInitBitmaps();
} }


void RefreshObjectButtons(void)
{
UDWORD i;

for (i = 0; i < NUM_OBJECTBUFFERS; i++)
{
RENDERBUTTON_NOTINITIALISED(&ObjectBuffers[i]);
}
}

void RefreshSystem0Buttons(void)
{
UDWORD i;

for (i = 0; i < NUM_SYSTEM0BUFFERS; i++)
{
RENDERBUTTON_NOTINITIALISED(&System0Buffers[i]);
}
}
void RefreshTopicButtons(void)
{
UDWORD i;

for (i = 0; i < NUM_TOPICBUFFERS; i++)
{
RENDERBUTTON_NOTINITIALISED(&TopicBuffers[i]);
}
}


void RefreshStatsButtons(void)
{
UDWORD i;

for (i = 0; i < NUM_STATBUFFERS; i++)
{
RENDERBUTTON_NOTINITIALISED(&StatBuffers[i]);
}
}


void ClearObjectBuffers(void) void ClearObjectBuffers(void)
{ {
UDWORD i; UDWORD i;
Expand All @@ -1647,17 +1585,15 @@ void ClearTopicBuffers(void)


void ClearObjectButtonBuffer(SDWORD BufferID) void ClearObjectButtonBuffer(SDWORD BufferID)
{ {
RENDERBUTTON_NOTINITIALISED(&ObjectBuffers[BufferID]); // what have I done ObjectBuffers[BufferID].InUse = false;
RENDERBUTTON_NOTINUSE(&ObjectBuffers[BufferID]);
ObjectBuffers[BufferID].Data = NULL; ObjectBuffers[BufferID].Data = NULL;
ObjectBuffers[BufferID].Data2 = NULL; ObjectBuffers[BufferID].Data2 = NULL;
ObjectBuffers[BufferID].ImdRotation = DEFAULT_BUTTON_ROTATION; ObjectBuffers[BufferID].ImdRotation = DEFAULT_BUTTON_ROTATION;
} }


void ClearTopicButtonBuffer(SDWORD BufferID) void ClearTopicButtonBuffer(SDWORD BufferID)
{ {
RENDERBUTTON_NOTINITIALISED(&TopicBuffers[BufferID]); // what have I done TopicBuffers[BufferID].InUse = false;
RENDERBUTTON_NOTINUSE(&TopicBuffers[BufferID]);
TopicBuffers[BufferID].Data = NULL; TopicBuffers[BufferID].Data = NULL;
TopicBuffers[BufferID].Data2 = NULL; TopicBuffers[BufferID].Data2 = NULL;
TopicBuffers[BufferID].ImdRotation = DEFAULT_BUTTON_ROTATION; TopicBuffers[BufferID].ImdRotation = DEFAULT_BUTTON_ROTATION;
Expand All @@ -1669,7 +1605,7 @@ SDWORD GetObjectBuffer(void)


for (i = 0; i < NUM_OBJECTBUFFERS; i++) for (i = 0; i < NUM_OBJECTBUFFERS; i++)
{ {
if (IsBufferInUse(&ObjectBuffers[i]) == false) if (!ObjectBuffers[i].InUse)
{ {
return i; return i;
} }
Expand All @@ -1684,8 +1620,7 @@ void ClearStatBuffers(void)


for (i = 0; i < NUM_STATBUFFERS; i++) for (i = 0; i < NUM_STATBUFFERS; i++)
{ {
RENDERBUTTON_NOTINITIALISED(&StatBuffers[i]); // what have I done StatBuffers[i].InUse = false;
RENDERBUTTON_NOTINUSE(&StatBuffers[i]);
StatBuffers[i].Data = NULL; StatBuffers[i].Data = NULL;
StatBuffers[i].ImdRotation = DEFAULT_BUTTON_ROTATION; StatBuffers[i].ImdRotation = DEFAULT_BUTTON_ROTATION;
} }
Expand All @@ -1697,7 +1632,7 @@ SDWORD GetStatBuffer(void)


for (i = 0; i < NUM_STATBUFFERS; i++) for (i = 0; i < NUM_STATBUFFERS; i++)
{ {
if (IsBufferInUse(&StatBuffers[i]) == false) if (!StatBuffers[i].InUse)
{ {
return i; return i;
} }
Expand All @@ -1720,8 +1655,7 @@ void ClearSystem0Buffers(void)


void ClearSystem0ButtonBuffer(SDWORD BufferID) void ClearSystem0ButtonBuffer(SDWORD BufferID)
{ {
RENDERBUTTON_NOTINITIALISED(&System0Buffers[BufferID]); // what have I done System0Buffers[BufferID].InUse = false;
RENDERBUTTON_NOTINUSE(&System0Buffers[BufferID]);
System0Buffers[BufferID].Data = NULL; System0Buffers[BufferID].Data = NULL;
System0Buffers[BufferID].Data2 = NULL; System0Buffers[BufferID].Data2 = NULL;
System0Buffers[BufferID].ImdRotation = DEFAULT_BUTTON_ROTATION; System0Buffers[BufferID].ImdRotation = DEFAULT_BUTTON_ROTATION;
Expand All @@ -1733,7 +1667,7 @@ SDWORD GetSystem0Buffer(void)


for (i = 0; i < NUM_SYSTEM0BUFFERS; i++) for (i = 0; i < NUM_SYSTEM0BUFFERS; i++)
{ {
if (IsBufferInUse(&System0Buffers[i]) == false) if (!System0Buffers[i].InUse)
{ {
return i; return i;
} }
Expand Down Expand Up @@ -2641,8 +2575,6 @@ void intDisplayTransportButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED); Buffer->ImdRotation += realTimeAdjustedAverage(BUTTONOBJ_ROTSPEED);
} }


Buffer->State = Form->state;

if (psDroid) if (psDroid)
{ {
RenderToButton(NULL, 0, psDroid, psDroid->player, Buffer, Down, IMDTYPE_DROID, TOPBUTTON); RenderToButton(NULL, 0, psDroid, psDroid->player, Buffer, Down, IMDTYPE_DROID, TOPBUTTON);
Expand All @@ -2651,7 +2583,6 @@ void intDisplayTransportButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
{ {
RenderBlankToButton(Buffer, Down, TOPBUTTON); RenderBlankToButton(Buffer, Down, TOPBUTTON);
} }
RENDERBUTTON_INITIALISED(Buffer);


if (Hilight) if (Hilight)
{ {
Expand Down
14 changes: 0 additions & 14 deletions src/intdisplay.h
Expand Up @@ -61,19 +61,11 @@ enum {
}; };


#define RENDERBUTTON_INUSE(x) ((x)->InUse=true) #define RENDERBUTTON_INUSE(x) ((x)->InUse=true)
#define RENDERBUTTON_NOTINUSE(x) ((x)->InUse=false)

#define RENDERBUTTON_INITIALISED(x) ((x)->Initialised=true)
#define RENDERBUTTON_NOTINITIALISED(x) ((x)->Initialised=false)

#define IsBufferInUse(x) ((x)->InUse)


struct RENDERED_BUTTON struct RENDERED_BUTTON
{ {
bool InUse; // Is it in use. bool InUse; // Is it in use.
bool Initialised; // Is it initialised.
SDWORD ImdRotation; // Rotation if button is an IMD. SDWORD ImdRotation; // Rotation if button is an IMD.
UDWORD State; // Copy of widget's state so we know if state has changed.
void *Data; // Any data we want to attach. void *Data; // Any data we want to attach.
void *Data2; // Any data we want to attach. void *Data2; // Any data we want to attach.
}; };
Expand Down Expand Up @@ -106,12 +98,6 @@ void ClearObjectButtonBuffer(SDWORD BufferID);
// Clear ( make unused ) a RENDERED_BUTTON structure. // Clear ( make unused ) a RENDERED_BUTTON structure.
void ClearTopicButtonBuffer(SDWORD BufferID); void ClearTopicButtonBuffer(SDWORD BufferID);


void RefreshObjectButtons(void);
void RefreshSystem0Buttons(void);
void RefreshTopicButtons(void);
void RefreshStatsButtons(void);


// Get a free RENDERED_BUTTON structure for a stat window button. // Get a free RENDERED_BUTTON structure for a stat window button.
SDWORD GetStatBuffer(void); SDWORD GetStatBuffer(void);


Expand Down
21 changes: 0 additions & 21 deletions src/transporter.cpp
Expand Up @@ -58,9 +58,7 @@
#include "qtscript.h" #include "qtscript.h"


//#define IDTRANS_FORM 9000 //The Transporter base form //#define IDTRANS_FORM 9000 //The Transporter base form
#define IDTRANS_TABFORM 9001 //The Transporter tabbed form
#define IDTRANS_CLOSE 9002 //The close button icon #define IDTRANS_CLOSE 9002 //The close button icon
#define IDTRANS_CONTABFORM 9004 //The Transporter Contents tabbed form
#define IDTRANS_CONTCLOSE 9005 //The close icon on the Contents form #define IDTRANS_CONTCLOSE 9005 //The close icon on the Contents form
#define IDTRANS_DROIDTAB 9007 //The Droid tab form #define IDTRANS_DROIDTAB 9007 //The Droid tab form
#define IDTRANS_DROIDCLOSE 9008 //The close icon for the Droid form #define IDTRANS_DROIDCLOSE 9008 //The close icon for the Droid form
Expand Down Expand Up @@ -427,7 +425,6 @@ bool intAddTransButtonForm(void)


/* Add the button form */ /* Add the button form */
IntListTabWidget *transList = new IntListTabWidget(transForm); IntListTabWidget *transList = new IntListTabWidget(transForm);
transList->id = IDTRANS_TABFORM;
transList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT*2); transList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT*2);
transList->setChildSpacing(OBJ_GAP, OBJ_GAP); transList->setChildSpacing(OBJ_GAP, OBJ_GAP);
int objListWidth = OBJ_BUTWIDTH*5 + OBJ_GAP*4; int objListWidth = OBJ_BUTWIDTH*5 + OBJ_GAP*4;
Expand Down Expand Up @@ -509,7 +506,6 @@ bool intAddTransContentsForm(void)


/* Add the contents form */ /* Add the contents form */
IntListTabWidget *contList = new IntListTabWidget(contForm); IntListTabWidget *contList = new IntListTabWidget(contForm);
contList->id = IDTRANS_CONTABFORM;
contList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT); contList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
contList->setChildSpacing(OBJ_GAP, OBJ_GAP); contList->setChildSpacing(OBJ_GAP, OBJ_GAP);
int contListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP; int contListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP;
Expand Down Expand Up @@ -805,23 +801,6 @@ static void _intProcessTransporter(UDWORD id)
is called by intTransporterAddDroid()*/ is called by intTransporterAddDroid()*/
} }
} }
// Process form tab clicks.
else if (id == IDTRANS_TABFORM)
{
//If tab clicked on Transporter screen then refresh rendered buttons.
RefreshObjectButtons();
RefreshTopicButtons();
}
else if (id == IDTRANS_CONTABFORM)
{
//If tab clicked on Transporter Contents screen then refresh rendered buttons.
RefreshStatsButtons();
}
else if (id == IDTRANS_DROIDTAB)
{
//If tab clicked on Droids Available screen then refresh rendered buttons.
RefreshSystem0Buttons();
}
} }


/* Remove the Transporter widgets from the screen */ /* Remove the Transporter widgets from the screen */
Expand Down

0 comments on commit 2521e71

Please sign in to comment.