editor: consolidate the four status text fields in one function

Only a very minor improvement in terms of lines-of-code, but still.
Günther Brammer 2010-12-14 02:06:23 +01:00
parent 511e835955
commit 8c2d2d3cc1
7 changed files with 18 additions and 27 deletions

View File

@ -134,9 +134,9 @@ void C4Console::DoHalt()
Game.Pause(); Game.Pause();
} }
bool C4Console::UpdateStatusBars() void C4Console::UpdateStatusBars()
{ {
if (!Active) return false; if (!Active) return;
// Frame counter // Frame counter
if (Game.FrameCounter!=FrameCounter) if (Game.FrameCounter!=FrameCounter)
{ {
@ -162,7 +162,6 @@ bool C4Console::UpdateStatusBars()
str.Format("%02d:%02d:%02d (%i FPS)",Time/3600,(Time%3600)/60,Time%60,FPS); str.Format("%02d:%02d:%02d (%i FPS)",Time/3600,(Time%3600)/60,Time%60,FPS);
C4ConsoleGUI::DisplayInfoText(CONSOLE_TimeFPS, str); C4ConsoleGUI::DisplayInfoText(CONSOLE_TimeFPS, str);
} }
return true;
} }
bool C4Console::SaveGame(bool fSaveGame) bool C4Console::SaveGame(bool fSaveGame)

View File

@ -74,7 +74,7 @@ public:
bool CloseGame(); bool CloseGame();
bool UpdatePlayerMenu(); bool UpdatePlayerMenu();
bool UpdateViewportMenu(); bool UpdateViewportMenu();
bool UpdateStatusBars(); void UpdateStatusBars();
// Menu // Menu
void ClearViewportMenu(); void ClearViewportMenu();
void UpdateNetMenu(); void UpdateNetMenu();

View File

@ -627,9 +627,14 @@ void C4ConsoleGUI::State::Clear()
void C4ConsoleGUI::DisplayInfoText(InfoTextType type, StdStrBuf& text) void C4ConsoleGUI::DisplayInfoText(InfoTextType type, StdStrBuf& text)
{ {
if (!Active)
return;
GtkWidget* label; GtkWidget* label;
switch (type) switch (type)
{ {
case CONSOLE_Cursor:
label = state->lblCursor;
break;
case CONSOLE_FrameCounter: case CONSOLE_FrameCounter:
label = state->lblFrame; label = state->lblFrame;
break; break;
@ -680,14 +685,6 @@ void C4ConsoleGUI::ShowAboutWithCopyright(StdStrBuf &copyright)
gtk_show_about_dialog(GTK_WINDOW(window), "name", C4ENGINECAPTION, "version", C4VERSION, "copyright", copyright.getData(), NULL); gtk_show_about_dialog(GTK_WINDOW(window), "name", C4ENGINECAPTION, "version", C4VERSION, "copyright", copyright.getData(), NULL);
} }
bool C4ConsoleGUI::UpdateCursorBar(const char *szCursor)
{
if (!Active)
return false;
gtk_label_set_label(GTK_LABEL(state->lblCursor), szCursor);
return true;
}
bool C4ConsoleGUI::UpdateModeCtrls(int iMode) bool C4ConsoleGUI::UpdateModeCtrls(int iMode)
{ {
if (!Active) if (!Active)

View File

@ -58,6 +58,7 @@ public:
enum InfoTextType enum InfoTextType
{ {
CONSOLE_Cursor,
CONSOLE_FrameCounter, CONSOLE_FrameCounter,
CONSOLE_ScriptCounter, CONSOLE_ScriptCounter,
CONSOLE_TimeFPS CONSOLE_TimeFPS
@ -90,7 +91,6 @@ public:
void SetCursor(Cursor cursor); void SetCursor(Cursor cursor);
void RecordingEnabled(); void RecordingEnabled();
void ShowAboutWithCopyright(StdStrBuf &copyright); void ShowAboutWithCopyright(StdStrBuf &copyright);
bool UpdateCursorBar(const char *szCursor);
bool UpdateModeCtrls(int iMode); bool UpdateModeCtrls(int iMode);
void UpdateNetMenu(Stage stage); void UpdateNetMenu(Stage stage);
void ClearNetMenu(Stage stage); void ClearNetMenu(Stage stage);

View File

@ -728,9 +728,14 @@ void C4ConsoleGUI::SetCaptionToFileName(const char* file_name)
void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType type, StdStrBuf& text) void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType type, StdStrBuf& text)
{ {
if (!Active)
return;
int dialog_item; int dialog_item;
switch (type) switch (type)
{ {
case CONSOLE_Cursor:
dialog_item = IDC_STATICCURSOR;
break;
case CONSOLE_FrameCounter: case CONSOLE_FrameCounter:
dialog_item = IDC_STATICFRAME; dialog_item = IDC_STATICFRAME;
break; break;
@ -763,16 +768,6 @@ void C4ConsoleGUI::ShowAboutWithCopyright(StdStrBuf &copyright)
MessageBox(NULL, strMessage.getData(), C4ENGINECAPTION, MB_ICONINFORMATION | MB_TASKMODAL); MessageBox(NULL, strMessage.getData(), C4ENGINECAPTION, MB_ICONINFORMATION | MB_TASKMODAL);
} }
bool C4ConsoleGUI::UpdateCursorBar(const char *szCursor)
{
if (!Active)
return false;
// Cursor
SetDlgItemText(hWindow,IDC_STATICCURSOR,szCursor);
UpdateWindow(GetDlgItem(hWindow,IDC_STATICCURSOR));
return true;
}
bool C4ConsoleGUI::FileSelect(char *sFilename, int iSize, const char * szFilter, DWORD dwFlags, bool fSave) bool C4ConsoleGUI::FileSelect(char *sFilename, int iSize, const char * szFilter, DWORD dwFlags, bool fSave)
{ {
OPENFILENAME ofn; OPENFILENAME ofn;

View File

@ -187,7 +187,7 @@ bool C4EditCursor::Move(float iX, float iY, WORD wKeyFlags)
return true; return true;
} }
bool C4EditCursor::UpdateStatusBar() void C4EditCursor::UpdateStatusBar()
{ {
int32_t X=this->X, Y=this->Y; int32_t X=this->X, Y=this->Y;
StdStrBuf str; StdStrBuf str;
@ -207,7 +207,7 @@ bool C4EditCursor::UpdateStatusBar()
break; break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
} }
return Console.UpdateCursorBar(str.getData()); Console.DisplayInfoText(C4ConsoleGUI::CONSOLE_Cursor, str);
} }
void C4EditCursor::OnSelectionChanged() void C4EditCursor::OnSelectionChanged()

View File

@ -82,7 +82,7 @@ public:
bool AltDown(); bool AltDown();
bool AltUp(); bool AltUp();
protected: protected:
bool UpdateStatusBar(); void UpdateStatusBar();
void ApplyToolPicker(); void ApplyToolPicker();
void ToolFailure(); void ToolFailure();
void PutContents(); void PutContents();