Change return type of CreateConsoleWindow to bool

All implementations were just returning `this` anyway, and this makes it
easier to add a corresponding cleanup function.
console-destruction
Armin Burgmeier 2016-09-30 22:23:15 -10:00
parent 836927d93c
commit a56d2fecdb
5 changed files with 16 additions and 12 deletions

View File

@ -62,7 +62,9 @@ C4Console::~C4Console()
C4Window * C4Console::Init(C4AbstractApp * pApp)
{
return C4ConsoleGUI::CreateConsoleWindow(pApp);
if (!C4ConsoleGUI::CreateConsoleWindow(pApp))
return NULL;
return this;
}
bool C4Console::In(const char *szText)
@ -613,10 +615,12 @@ bool C4ConsoleGUI::ClearLog() {return 0;}
void C4ConsoleGUI::ClearNetMenu() {}
void C4ConsoleGUI::ClearPlayerMenu() {}
void C4ConsoleGUI::ClearViewportMenu() {}
C4Window * C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp * pApp)
bool C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp * pApp)
{
C4Rect r(0, 0, 400, 350);
return C4Window::Init(C4Window::W_Console, pApp, LoadResStr("IDS_CNS_CONSOLE"), &r);
if (!C4Window::Init(C4Window::W_Console, pApp, LoadResStr("IDS_CNS_CONSOLE"), &r))
return false;
return true;
}
void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType, StdStrBuf&) {}
void C4ConsoleGUI::DoEnableControls(bool) {}

View File

@ -63,14 +63,14 @@ public:
void Clear() {}
};
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
bool C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
{
C4WindowController* controller = [C4EditorWindowController new];
setObjectiveCObject(controller);
[NSBundle loadNibNamed:@"Editor" owner:controller];
[controller setStdWindow:this];
this->Active = true;
return this;
return true;
}
void C4ConsoleGUI::Out(const char* message)

View File

@ -122,7 +122,7 @@ public:
void ClearPlayerMenu();
void SetInputFunctions(std::list<const char*> &functions);
C4Window* CreateConsoleWindow(C4AbstractApp *application);
bool CreateConsoleWindow(C4AbstractApp *application);
void Out(const char* message);
bool ClearLog();
void DisplayInfoText(InfoTextType type, StdStrBuf& text);

View File

@ -82,12 +82,12 @@ void C4ConsoleGUI::SetInputFunctions(std::list<const char*> &functions)
if (Active) state->SetInputFunctions(functions);
}
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
bool C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
{
if (!state->CreateConsoleWindow(application)) return NULL;
if (!state->CreateConsoleWindow(application)) return false;
Active = true;
EnableControls(fGameOpen);
return this;
return true;
}
void C4ConsoleGUI::Out(const char* message)

View File

@ -783,7 +783,7 @@ bool C4ConsoleGUI::UpdateModeCtrls(int iMode)
return true;
}
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
bool C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
{
hWindow = CreateDialog(application->GetInstance(), MAKEINTRESOURCE(IDD_CONSOLE), NULL, ConsoleDlgProc);
if (!hWindow)
@ -802,7 +802,7 @@ C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
Log(FormatString("Error creating dialog window: %s", StdStrBuf(lpMsgBuf).getData()).getData());
// Free the buffer.
LocalFree(lpMsgBuf);
return NULL;
return false;
}
// Remember metrics
state->console_handle = hWindow;
@ -827,7 +827,7 @@ C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
ShowCursor(true);
renderwnd = hWindow;
// Success
return this;
return true;
}
void C4ConsoleGUI::DoEnableControls(bool fEnable)