qt editor: Add "Editor" button to startup main menu

qteditor
Sven Eberhardt 2016-03-26 02:15:15 -04:00
parent f2daa51fa7
commit b3712ace97
4 changed files with 38 additions and 0 deletions

View File

@ -260,6 +260,7 @@ IDS_DLGTIP_CHATWIN=Nachrichten
IDS_DLGTIP_CLEAR=Löscht die Auswahl
IDS_DLGTIP_COPY=Kopiert die Auswahl in die Zwischenablage
IDS_DLGTIP_CUT=Schneidet die Auswahl aus und kopiert sie in die Zwischenablage
IDS_DLGTIP_EDITOR=Erstelle eigene Szenarien!
IDS_DLGTIP_EXIT=Beendet das Programm.
IDS_DLGTIP_GAMEGO=Startet das Spiel.
IDS_DLGTIP_NETWORKGAME=Startet ein Netzwerkspiel oder tritt einem laufenden Netzwerkspiel bei.
@ -301,6 +302,7 @@ IDS_DLG_CUT=Ausschneiden
IDS_DLG_DEFINITION=Objektdefinition
IDS_DLG_DEFINITIONS=Objektdefinitionen
IDS_DLG_DYNAMIC=Dynamische Landschaft
IDS_DLG_EDITOR=Editor
IDS_DLG_ERROR=Fehler
IDS_DLG_EXACT=Exakte Landschaft
IDS_DLG_EXIT=&Beenden
@ -416,6 +418,7 @@ IDS_ERR_SAVE_RUNTIMEDATA=Spiel speichern: Fehler beim Speichern von Laufzeitspie
IDS_ERR_SAVE_SCENSECTIONS=Spiel speichern: Fehler beim Speichern der Szenariensektionen
IDS_ERR_SAVE_TARGETGRP=Spiel speichern: Zielgruppe kann nicht als %s erzeugt werden.
IDS_ERR_SCENSECTION=Fehler beim Laden des Szenarienteils "%s"
IDS_ERR_STARTEDITOR=Fehler beim Starten des Editors.
IDS_ERR_SWITCHRES=Fehler beim Ändern der Bildschirmauflösung: %s
IDS_ERR_TITLE=Fehler
IDS_ERR_TODO=Fehler beim Schreiben in TODO-Datei.

View File

@ -260,6 +260,7 @@ IDS_DLGTIP_CHATWIN=Messages
IDS_DLGTIP_CLEAR=Clears the selection.
IDS_DLGTIP_COPY=Copies the selection to the clipboard.
IDS_DLGTIP_CUT=Moves the selection to the clipboard.
IDS_DLGTIP_EDITOR=Create your own scenarios.
IDS_DLGTIP_EXIT=End the program.
IDS_DLGTIP_GAMEGO=Starts the game.
IDS_DLGTIP_NETWORKGAME=Start a network game or join an existing one.
@ -301,6 +302,7 @@ IDS_DLG_CUT=Cut
IDS_DLG_DEFINITION=Object Definition
IDS_DLG_DEFINITIONS=Object Definitions
IDS_DLG_DYNAMIC=Dynamic landscape
IDS_DLG_EDITOR=Editor
IDS_DLG_ERROR=Error
IDS_DLG_EXACT=Exact landscape
IDS_DLG_EXIT=E&xit
@ -416,6 +418,7 @@ IDS_ERR_SAVE_RUNTIMEDATA=SaveGame: Error saving game data
IDS_ERR_SAVE_SCENSECTIONS=SaveGame: Error saving scenario sections
IDS_ERR_SAVE_TARGETGRP=SaveGame: Unable to create target group at %s.
IDS_ERR_SCENSECTION=Error loading scenario section "%s"
IDS_ERR_STARTEDITOR=Error starting editor.
IDS_ERR_SWITCHRES=Error switching resolution: %s
IDS_ERR_TITLE=Error
IDS_ERR_TODO=Error writing to TODO file.

View File

@ -33,6 +33,10 @@
#include <C4Language.h>
#include <C4GraphicsResource.h>
#ifdef USE_WIN32_WINDOWS
#include <shellapi.h>
#endif
C4StartupMainDlg::C4StartupMainDlg() : C4StartupDlg(NULL) // create w/o title; it is drawn in custom draw proc
{
@ -59,6 +63,11 @@ C4StartupMainDlg::C4StartupMainDlg() : C4StartupDlg(NULL) // create w/o title; i
AddElement(btn = new C4GUI::CallbackButton<C4StartupMainDlg>(LoadResStr("IDS_DLG_OPTIONS"), caButtons.GetFromTop(iButtonHeight), &C4StartupMainDlg::OnOptionsBtn));
btn->SetToolTip(LoadResStr("IDS_DLGTIP_OPTIONS"));
btn->SetCustomGraphics(&C4Startup::Get()->Graphics.barMainButtons, &C4Startup::Get()->Graphics.barMainButtonsDown);
#ifdef WITH_QT_EDITOR
AddElement(btn = new C4GUI::CallbackButton<C4StartupMainDlg>(LoadResStr("IDS_DLG_EDITOR"), caButtons.GetFromTop(iButtonHeight), &C4StartupMainDlg::OnEditorBtn));
btn->SetToolTip(LoadResStr("IDS_DLGTIP_EDITOR"));
btn->SetCustomGraphics(&C4Startup::Get()->Graphics.barMainButtons, &C4Startup::Get()->Graphics.barMainButtonsDown);
#endif
AddElement(btn = new C4GUI::CallbackButton<C4StartupMainDlg>(LoadResStr("IDS_DLG_ABOUT"), caButtons.GetFromTop(iButtonHeight), &C4StartupMainDlg::OnAboutBtn));
btn->SetToolTip(LoadResStr("IDS_DLGTIP_ABOUT"));
btn->SetCustomGraphics(&C4Startup::Get()->Graphics.barMainButtons, &C4Startup::Get()->Graphics.barMainButtonsDown);
@ -245,6 +254,28 @@ void C4StartupMainDlg::OnOptionsBtn(C4GUI::Control *btn)
C4Startup::Get()->SwitchDialog(C4Startup::SDID_Options);
}
void C4StartupMainDlg::OnEditorBtn(C4GUI::Control *btn)
{
// restart in editor mode
bool success = false;
#ifdef USE_WIN32_WINDOWS
wchar_t buf[_MAX_PATH];
DWORD sz = ::GetModuleFileName(::GetModuleHandle(NULL), buf, _MAX_PATH);
if (sz)
{
intptr_t iError = (intptr_t)::ShellExecute(NULL, NULL, buf, L"--editor", Config.General.ExePath.GetWideChar(), SW_SHOW);
if (iError > 32) success = true;
}
#else
TODO start editor
#endif
// must quit ourselves for editor to be shown
if (success)
Application.Quit();
else
C4GUI::TheScreen.ShowErrorMessage(LoadResStr("IDS_ERR_STARTEDITOR"));
}
void C4StartupMainDlg::OnAboutBtn(C4GUI::Control *btn)
{
// advance to about screen

View File

@ -47,6 +47,7 @@ protected:
void OnNetJoinBtn(C4GUI::Control *btn); // callback: join net work game (direct join only for now)
void OnNetJoin(const StdStrBuf &rsHostAddress);
void OnOptionsBtn(C4GUI::Control *btn); // callback: Show options screen
void OnEditorBtn(C4GUI::Control *btn); // callback: Editor
void OnAboutBtn(C4GUI::Control *btn); // callback: Show about screen
void OnExitBtn(C4GUI::Control *btn); // callback: exit button pressed
void OnTODO(C4GUI::Control *btn); // button not yet implemented