Skip to content

Update design form lists when research is completed #3838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading