forked from Mirrors/openclonk
Compare commits
4 Commits
master
...
console-de
Author | SHA1 | Date |
---|---|---|
Armin Burgmeier | e39a3a40f7 | |
Armin Burgmeier | 4e7b396d31 | |
Armin Burgmeier | 2d324c10e0 | |
Armin Burgmeier | a56d2fecdb |
|
@ -62,7 +62,9 @@ C4Console::~C4Console()
|
||||||
|
|
||||||
C4Window * C4Console::Init(C4AbstractApp * pApp)
|
C4Window * C4Console::Init(C4AbstractApp * pApp)
|
||||||
{
|
{
|
||||||
return C4ConsoleGUI::CreateConsoleWindow(pApp);
|
if (!C4ConsoleGUI::CreateConsoleWindow(pApp))
|
||||||
|
return NULL;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4Console::In(const char *szText)
|
bool C4Console::In(const char *szText)
|
||||||
|
@ -366,15 +368,18 @@ void C4Console::Default()
|
||||||
|
|
||||||
void C4Console::Clear()
|
void C4Console::Clear()
|
||||||
{
|
{
|
||||||
|
if (pSurface) delete pSurface;
|
||||||
|
pSurface = 0;
|
||||||
|
|
||||||
C4Window::Clear();
|
C4Window::Clear();
|
||||||
|
C4ConsoleGUI::DeleteConsoleWindow();
|
||||||
|
|
||||||
EditCursor.Clear();
|
EditCursor.Clear();
|
||||||
ToolsDlg.Clear();
|
ToolsDlg.Clear();
|
||||||
PropertyDlgClose();
|
PropertyDlgClose();
|
||||||
ClearViewportMenu();
|
ClearViewportMenu();
|
||||||
ClearPlayerMenu();
|
ClearPlayerMenu();
|
||||||
ClearNetMenu();
|
ClearNetMenu();
|
||||||
if (pSurface) delete pSurface;
|
|
||||||
pSurface = 0;
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
Application.Quit();
|
Application.Quit();
|
||||||
#endif
|
#endif
|
||||||
|
@ -613,11 +618,14 @@ bool C4ConsoleGUI::ClearLog() {return 0;}
|
||||||
void C4ConsoleGUI::ClearNetMenu() {}
|
void C4ConsoleGUI::ClearNetMenu() {}
|
||||||
void C4ConsoleGUI::ClearPlayerMenu() {}
|
void C4ConsoleGUI::ClearPlayerMenu() {}
|
||||||
void C4ConsoleGUI::ClearViewportMenu() {}
|
void C4ConsoleGUI::ClearViewportMenu() {}
|
||||||
C4Window * C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp * pApp)
|
bool C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp * pApp)
|
||||||
{
|
{
|
||||||
C4Rect r(0, 0, 400, 350);
|
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::DeleteConsoleWindow() {}
|
||||||
void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType, StdStrBuf&) {}
|
void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType, StdStrBuf&) {}
|
||||||
void C4ConsoleGUI::DoEnableControls(bool) {}
|
void C4ConsoleGUI::DoEnableControls(bool) {}
|
||||||
bool C4ConsoleGUI::DoUpdateHaltCtrls(bool) {return 0;}
|
bool C4ConsoleGUI::DoUpdateHaltCtrls(bool) {return 0;}
|
||||||
|
|
|
@ -63,14 +63,18 @@ public:
|
||||||
void Clear() {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
|
bool C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
|
||||||
{
|
{
|
||||||
C4WindowController* controller = [C4EditorWindowController new];
|
C4WindowController* controller = [C4EditorWindowController new];
|
||||||
setObjectiveCObject(controller);
|
setObjectiveCObject(controller);
|
||||||
[NSBundle loadNibNamed:@"Editor" owner:controller];
|
[NSBundle loadNibNamed:@"Editor" owner:controller];
|
||||||
[controller setStdWindow:this];
|
[controller setStdWindow:this];
|
||||||
this->Active = true;
|
this->Active = true;
|
||||||
return this;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void C4ConsoleGUI::DeleteConsoleWindow()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4ConsoleGUI::Out(const char* message)
|
void C4ConsoleGUI::Out(const char* message)
|
||||||
|
|
|
@ -122,7 +122,8 @@ public:
|
||||||
void ClearPlayerMenu();
|
void ClearPlayerMenu();
|
||||||
void SetInputFunctions(std::list<const char*> &functions);
|
void SetInputFunctions(std::list<const char*> &functions);
|
||||||
|
|
||||||
C4Window* CreateConsoleWindow(C4AbstractApp *application);
|
bool CreateConsoleWindow(C4AbstractApp *application);
|
||||||
|
void DeleteConsoleWindow();
|
||||||
void Out(const char* message);
|
void Out(const char* message);
|
||||||
bool ClearLog();
|
bool ClearLog();
|
||||||
void DisplayInfoText(InfoTextType type, StdStrBuf& text);
|
void DisplayInfoText(InfoTextType type, StdStrBuf& text);
|
||||||
|
|
|
@ -82,12 +82,21 @@ void C4ConsoleGUI::SetInputFunctions(std::list<const char*> &functions)
|
||||||
if (Active) state->SetInputFunctions(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;
|
Active = true;
|
||||||
EnableControls(fGameOpen);
|
EnableControls(fGameOpen);
|
||||||
return this;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void C4ConsoleGUI::DeleteConsoleWindow()
|
||||||
|
{
|
||||||
|
if (Active)
|
||||||
|
{
|
||||||
|
Active = false;
|
||||||
|
state->DeleteConsoleWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4ConsoleGUI::Out(const char* message)
|
void C4ConsoleGUI::Out(const char* message)
|
||||||
|
|
|
@ -734,6 +734,46 @@ bool C4ConsoleGUIState::CreateConsoleWindow(C4AbstractApp *app)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C4ConsoleGUIState::DeleteConsoleWindow()
|
||||||
|
{
|
||||||
|
// Reset to a state before CreateConsoleWindow was called
|
||||||
|
action_object = C4VNull;
|
||||||
|
is_object_selection_updating = false;
|
||||||
|
|
||||||
|
editcursor_mode = C4CNS_ModePlay;
|
||||||
|
drawing_tool = C4TLS_Brush;
|
||||||
|
landscape_mode = LandscapeMode::Dynamic;
|
||||||
|
net_enabled = false;
|
||||||
|
recording = false;
|
||||||
|
enabled = false;
|
||||||
|
|
||||||
|
window_menu_separator = nullptr;
|
||||||
|
status_cursor = status_framecounter = status_timefps = nullptr;
|
||||||
|
|
||||||
|
while (!viewports.empty())
|
||||||
|
{
|
||||||
|
auto vp = viewports.front();
|
||||||
|
viewports.erase(viewports.begin());
|
||||||
|
|
||||||
|
viewport_area->removeDockWidget(vp);
|
||||||
|
delete vp;
|
||||||
|
}
|
||||||
|
|
||||||
|
client_actions.clear();
|
||||||
|
player_actions.clear();
|
||||||
|
viewport_actions.clear();
|
||||||
|
viewport_area = nullptr;
|
||||||
|
|
||||||
|
disable_shortcut_filter.reset(nullptr);
|
||||||
|
definition_list_model.reset(nullptr);
|
||||||
|
object_list_model.reset(nullptr);
|
||||||
|
property_name_delegate.reset(nullptr);
|
||||||
|
property_delegate_factory.reset(nullptr);
|
||||||
|
property_model.reset(nullptr);
|
||||||
|
window.reset(nullptr);
|
||||||
|
application.reset(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void C4ConsoleGUIState::Execute(bool redraw_only)
|
void C4ConsoleGUIState::Execute(bool redraw_only)
|
||||||
{
|
{
|
||||||
// Nothing to do - Qt's event loop is handling everything.
|
// Nothing to do - Qt's event loop is handling everything.
|
||||||
|
@ -875,12 +915,26 @@ void C4ConsoleGUIState::AddViewport(C4ViewportWindow *cvp)
|
||||||
void C4ConsoleGUIState::RemoveViewport(C4ViewportWindow *cvp)
|
void C4ConsoleGUIState::RemoveViewport(C4ViewportWindow *cvp)
|
||||||
{
|
{
|
||||||
if (!viewport_area) return;
|
if (!viewport_area) return;
|
||||||
for (auto vp : viewports)
|
|
||||||
|
for (auto iter = viewports.begin(); iter != viewports.end(); )
|
||||||
{
|
{
|
||||||
|
auto vp = *iter;
|
||||||
if (vp->GetViewportWindow() == cvp)
|
if (vp->GetViewportWindow() == cvp)
|
||||||
{
|
{
|
||||||
viewport_area->removeDockWidget(vp);
|
viewport_area->removeDockWidget(vp);
|
||||||
vp->deleteLater();
|
iter = viewports.erase(iter);
|
||||||
|
|
||||||
|
// cannot use deleteLater here because Qt will then
|
||||||
|
// still select/deselect the viewport's GL context
|
||||||
|
// behind the scenes, leaving us with an unselected
|
||||||
|
// GL context.
|
||||||
|
// Documented at http://doc.qt.io/qt-5/qopenglwidget.html
|
||||||
|
// Instead, delete the viewport widget directly.
|
||||||
|
delete vp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,6 +220,7 @@ public:
|
||||||
|
|
||||||
void AddToolbarSpacer(int space);
|
void AddToolbarSpacer(int space);
|
||||||
bool CreateConsoleWindow(C4AbstractApp *app);
|
bool CreateConsoleWindow(C4AbstractApp *app);
|
||||||
|
void DeleteConsoleWindow();
|
||||||
void Execute(bool redraw_only=false);
|
void Execute(bool redraw_only=false);
|
||||||
void Redraw() { Execute(true); }
|
void Redraw() { Execute(true); }
|
||||||
void UpdateActionStates();
|
void UpdateActionStates();
|
||||||
|
|
|
@ -524,9 +524,15 @@ void C4ConsoleQtViewportDockWidget::closeEvent(QCloseEvent * event)
|
||||||
QDockWidget::closeEvent(event);
|
QDockWidget::closeEvent(event);
|
||||||
if (event->isAccepted())
|
if (event->isAccepted())
|
||||||
{
|
{
|
||||||
if (cvp) cvp->Close();
|
if (cvp)
|
||||||
cvp = NULL;
|
{
|
||||||
deleteLater();
|
// This causes "this" to be deleted:
|
||||||
|
cvp->Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -783,7 +783,7 @@ bool C4ConsoleGUI::UpdateModeCtrls(int iMode)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
|
bool C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
|
||||||
{
|
{
|
||||||
hWindow = CreateDialog(application->GetInstance(), MAKEINTRESOURCE(IDD_CONSOLE), NULL, ConsoleDlgProc);
|
hWindow = CreateDialog(application->GetInstance(), MAKEINTRESOURCE(IDD_CONSOLE), NULL, ConsoleDlgProc);
|
||||||
if (!hWindow)
|
if (!hWindow)
|
||||||
|
@ -802,7 +802,7 @@ C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
|
||||||
Log(FormatString("Error creating dialog window: %s", StdStrBuf(lpMsgBuf).getData()).getData());
|
Log(FormatString("Error creating dialog window: %s", StdStrBuf(lpMsgBuf).getData()).getData());
|
||||||
// Free the buffer.
|
// Free the buffer.
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
return NULL;
|
return false;
|
||||||
}
|
}
|
||||||
// Remember metrics
|
// Remember metrics
|
||||||
state->console_handle = hWindow;
|
state->console_handle = hWindow;
|
||||||
|
@ -827,7 +827,11 @@ C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
|
||||||
ShowCursor(true);
|
ShowCursor(true);
|
||||||
renderwnd = hWindow;
|
renderwnd = hWindow;
|
||||||
// Success
|
// Success
|
||||||
return this;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void C4ConsoleGUI::DeleteConsoleWindow()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4ConsoleGUI::DoEnableControls(bool fEnable)
|
void C4ConsoleGUI::DoEnableControls(bool fEnable)
|
||||||
|
|
Loading…
Reference in New Issue