Skip to content

Commit

Permalink
Update design form lists when research is completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Monsterovich committed Jun 5, 2024
1 parent 63badba commit 713f126
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
22 changes: 16 additions & 6 deletions src/design.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3497,12 +3497,7 @@ void intProcessDesign(UDWORD id)
}
else
{
desSetupDesignTemplates();
widgDelete(psWScreen, IDDES_TEMPLBASE);
intAddTemplateForm(templateFromButtonId(droidTemplID));
intSetDesignMode(desCompMode, true);
droidTemplID = IDDES_TEMPLSTART;
widgSetButtonState(psWScreen, droidTemplID, WBUT_LOCK);
intRefreshDesign();
}
break;
}
Expand Down Expand Up @@ -3690,6 +3685,21 @@ void intRunDesign()
}
}

void intRefreshDesign()
{
auto designForm = widgGetFromID(psWScreen, IDDES_FORM);

if (designForm && designForm->visible())
{
desSetupDesignTemplates();
widgDelete(psWScreen, IDDES_TEMPLBASE);
intAddTemplateForm(templateFromButtonId(droidTemplID));
intSetDesignMode(desCompMode, true);
droidTemplID = IDDES_TEMPLSTART;
widgSetButtonState(psWScreen, droidTemplID, WBUT_LOCK);
}
}

static void intDisplayStatForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
{
static UDWORD iRY = 45;
Expand Down
1 change: 1 addition & 0 deletions src/design.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ bool intAddDesign(bool bShowCentreScreen);
void intRemoveDesign();
void intProcessDesign(UDWORD id);
void intRunDesign();
void intRefreshDesign();

const char *GetDefaultTemplateName(DROID_TEMPLATE *psTemplate);

Expand Down
14 changes: 10 additions & 4 deletions src/research.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "qtscript.h"
#include "stats.h"
#include "wzapi.h"
#include "design.h"

// The stores for the research stats
std::vector<RESEARCH> asResearch;
Expand Down Expand Up @@ -1149,11 +1150,16 @@ void researchResult(UDWORD researchIndex, UBYTE player, bool bDisplay, STRUCTURE
audio_QueueTrack(ID_SOUND_RESEARCH_COMPLETED);
}

if (player == selectedPlayer && bDisplay)
if (player == selectedPlayer)
{
//add console text message
snprintf(consoleMsg, MAX_RESEARCH_MSG_SIZE, _("Research completed: %s"), getLocalizedStatsName(pResearch));
addConsoleMessage(consoleMsg, LEFT_JUSTIFY, SYSTEM_MESSAGE);
if (bDisplay)
{
//add console text message
snprintf(consoleMsg, MAX_RESEARCH_MSG_SIZE, _("Research completed: %s"), getLocalizedStatsName(pResearch));
addConsoleMessage(consoleMsg, LEFT_JUSTIFY, SYSTEM_MESSAGE);
}

intRefreshDesign();
}

if (psResearchFacility)
Expand Down

0 comments on commit 713f126

Please sign in to comment.