forked from Mirrors/openclonk
Platform-specific code in C4Console.cpp gets factored out into C4Console(Win32/GTK).cpp
parent
5f68dd2edb
commit
44928f1a8d
|
@ -93,6 +93,7 @@ BuildLog.htm
|
||||||
|
|
||||||
# XCode temporary files + Xcode not temporary files
|
# XCode temporary files + Xcode not temporary files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
._*
|
||||||
xcode/build
|
xcode/build
|
||||||
*.xcodeproj
|
*.xcodeproj
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,8 @@ set(OC_CLONK_SOURCES
|
||||||
src/control/C4Teams.h
|
src/control/C4Teams.h
|
||||||
src/editor/C4Console.cpp
|
src/editor/C4Console.cpp
|
||||||
src/editor/C4Console.h
|
src/editor/C4Console.h
|
||||||
|
src/editor/C4ConsoleGUI.h
|
||||||
|
src/editor/C4ConsoleGUICommon.cpp
|
||||||
src/editor/C4DevmodeDlg.cpp
|
src/editor/C4DevmodeDlg.cpp
|
||||||
src/editor/C4DevmodeDlg.h
|
src/editor/C4DevmodeDlg.h
|
||||||
src/editor/C4EditCursor.cpp
|
src/editor/C4EditCursor.cpp
|
||||||
|
@ -478,6 +480,8 @@ set(OC_CLONK_SOURCES
|
||||||
src/platform/StdVideo.cpp
|
src/platform/StdVideo.cpp
|
||||||
src/platform/StdVideo.h
|
src/platform/StdVideo.h
|
||||||
src/platform/StdWindow.h
|
src/platform/StdWindow.h
|
||||||
|
src/platform/StdAppCommon.h
|
||||||
|
src/platform/StdAppCommon.cpp
|
||||||
src/script/C4AList.cpp
|
src/script/C4AList.cpp
|
||||||
src/script/C4AList.h
|
src/script/C4AList.h
|
||||||
src/script/C4Aul.cpp
|
src/script/C4Aul.cpp
|
||||||
|
@ -518,6 +522,7 @@ if(WIN32)
|
||||||
src/platform/StdJoystick.cpp
|
src/platform/StdJoystick.cpp
|
||||||
src/platform/StdJoystick.h
|
src/platform/StdJoystick.h
|
||||||
src/platform/C4FileClasses.cpp
|
src/platform/C4FileClasses.cpp
|
||||||
|
src/editor/C4ConsoleWin32.cpp
|
||||||
src/res/resource.h
|
src/res/resource.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -583,6 +588,7 @@ if(USE_GTK)
|
||||||
list(APPEND OC_SYSTEM_SOURCES
|
list(APPEND OC_SYSTEM_SOURCES
|
||||||
src/platform/StdGtkWindow.cpp
|
src/platform/StdGtkWindow.cpp
|
||||||
src/platform/StdGtkWindow.h
|
src/platform/StdGtkWindow.h
|
||||||
|
src/editor/C4ConsoleGTK.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,7 @@ void C4FullScreen::Execute()
|
||||||
// Execute menu
|
// Execute menu
|
||||||
if (pMenu) pMenu->Execute();
|
if (pMenu) pMenu->Execute();
|
||||||
// Draw
|
// Draw
|
||||||
::GraphicsSystem.Execute();
|
RequestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4FullScreen::ViewportCheck()
|
bool C4FullScreen::ViewportCheck()
|
||||||
|
@ -522,6 +522,11 @@ void C4FullScreen::CloseMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C4FullScreen::PerformUpdate()
|
||||||
|
{
|
||||||
|
GraphicsSystem.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
bool C4FullScreen::MenuKeyControl(BYTE byCom)
|
bool C4FullScreen::MenuKeyControl(BYTE byCom)
|
||||||
{
|
{
|
||||||
if (pMenu) return pMenu->KeyControl(byCom);
|
if (pMenu) return pMenu->KeyControl(byCom);
|
||||||
|
|
|
@ -50,9 +50,10 @@ public:
|
||||||
virtual void CharIn(const char * c);
|
virtual void CharIn(const char * c);
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
virtual void HandleMessage (XEvent &e);
|
virtual void HandleMessage (XEvent &e);
|
||||||
#elif USE_SDL_MAINLOOP
|
#elif defined(USE_SDL_MAINLOOP)
|
||||||
virtual void HandleMessage (SDL_Event &e);
|
virtual void HandleMessage (SDL_Event &e);
|
||||||
#endif
|
#endif
|
||||||
|
virtual void PerformUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern C4FullScreen FullScreen;
|
extern C4FullScreen FullScreen;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,6 +24,7 @@
|
||||||
#ifndef INC_C4Console
|
#ifndef INC_C4Console
|
||||||
#define INC_C4Console
|
#define INC_C4Console
|
||||||
|
|
||||||
|
#include "C4ConsoleGUI.h"
|
||||||
#include "C4PropertyDlg.h"
|
#include "C4PropertyDlg.h"
|
||||||
#include "C4ToolsDlg.h"
|
#include "C4ToolsDlg.h"
|
||||||
#include "C4ObjectListDlg.h"
|
#include "C4ObjectListDlg.h"
|
||||||
|
@ -31,10 +32,6 @@
|
||||||
|
|
||||||
#include <StdWindow.h>
|
#include <StdWindow.h>
|
||||||
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
# include <gtk/gtk.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const int C4CNS_ModePlay = 0,
|
const int C4CNS_ModePlay = 0,
|
||||||
C4CNS_ModeEdit = 1,
|
C4CNS_ModeEdit = 1,
|
||||||
C4CNS_ModeDraw = 2;
|
C4CNS_ModeDraw = 2;
|
||||||
|
@ -53,16 +50,11 @@ typedef CStdGtkWindow C4ConsoleBase;
|
||||||
typedef CStdWindow C4ConsoleBase;
|
typedef CStdWindow C4ConsoleBase;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class C4Console: public C4ConsoleBase
|
class C4Console: public C4ConsoleGUI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
C4Console();
|
C4Console();
|
||||||
virtual ~C4Console();
|
virtual ~C4Console();
|
||||||
bool Editing;
|
|
||||||
C4PropertyDlg PropertyDlg;
|
|
||||||
C4ToolsDlg ToolsDlg;
|
|
||||||
C4ObjectListDlg ObjectListDlg;
|
|
||||||
C4EditCursor EditCursor;
|
|
||||||
void Default();
|
void Default();
|
||||||
virtual void Clear();
|
virtual void Clear();
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
|
@ -71,28 +63,19 @@ public:
|
||||||
void Execute();
|
void Execute();
|
||||||
void ClearPointers(C4Object *pObj);
|
void ClearPointers(C4Object *pObj);
|
||||||
bool Message(const char *szMessage, bool fQuery=false);
|
bool Message(const char *szMessage, bool fQuery=false);
|
||||||
void SetCaption(const char *szCaption);
|
|
||||||
bool In(const char *szText);
|
bool In(const char *szText);
|
||||||
bool Out(const char *szText);
|
|
||||||
bool ClearLog(); // empty log text
|
|
||||||
void DoPlay();
|
void DoPlay();
|
||||||
void DoHalt();
|
void DoHalt();
|
||||||
bool UpdateCursorBar(const char *szCursor);
|
|
||||||
bool UpdateHaltCtrls(bool fHalt);
|
|
||||||
bool UpdateModeCtrls(int iMode);
|
|
||||||
void UpdateInputCtrl();
|
void UpdateInputCtrl();
|
||||||
void UpdateMenus();
|
void UpdateMenus();
|
||||||
bool OpenGame();
|
bool OpenGame();
|
||||||
bool TogglePause(); // key callpack: pause
|
bool TogglePause(); // key callpack: pause
|
||||||
protected:
|
public:
|
||||||
bool CloseGame();
|
bool CloseGame();
|
||||||
bool fGameOpen;
|
|
||||||
void EnableControls(bool fEnable);
|
|
||||||
bool UpdatePlayerMenu();
|
bool UpdatePlayerMenu();
|
||||||
bool UpdateViewportMenu();
|
bool UpdateViewportMenu();
|
||||||
bool UpdateStatusBars();
|
bool UpdateStatusBars();
|
||||||
// Menu
|
// Menu
|
||||||
void ClearPlayerMenu();
|
|
||||||
void ClearViewportMenu();
|
void ClearViewportMenu();
|
||||||
void UpdateNetMenu();
|
void UpdateNetMenu();
|
||||||
void ClearNetMenu();
|
void ClearNetMenu();
|
||||||
|
@ -113,6 +96,12 @@ protected:
|
||||||
bool FileClose();
|
bool FileClose();
|
||||||
bool FileQuit();
|
bool FileQuit();
|
||||||
bool FileRecord();
|
bool FileRecord();
|
||||||
|
void SetCaptionToFilename(const char* szFilename);
|
||||||
|
public:
|
||||||
|
C4PropertyDlg PropertyDlg;
|
||||||
|
C4ToolsDlg ToolsDlg;
|
||||||
|
C4ObjectListDlg ObjectListDlg;
|
||||||
|
C4EditCursor EditCursor;
|
||||||
|
|
||||||
int ScriptCounter;
|
int ScriptCounter;
|
||||||
int FrameCounter;
|
int FrameCounter;
|
||||||
|
@ -123,107 +112,7 @@ protected:
|
||||||
int MenuIndexViewport;
|
int MenuIndexViewport;
|
||||||
int MenuIndexNet;
|
int MenuIndexNet;
|
||||||
int MenuIndexHelp;
|
int MenuIndexHelp;
|
||||||
#ifdef _WIN32
|
#if defined(USE_X11) && !defined(WITH_DEVELOPER_MODE)
|
||||||
void UpdateMenuText(HMENU hMenu);
|
|
||||||
bool RegisterConsoleWindowClass(HINSTANCE hInst);
|
|
||||||
bool AddMenuItem(HMENU hMenu, DWORD dwID, const char *szString, bool fEnabled=true);
|
|
||||||
virtual bool Win32DialogMessageHandling(MSG * msg)
|
|
||||||
{
|
|
||||||
return (hWindow && IsDialogMessage(hWindow,msg)) || (PropertyDlg.hDialog && IsDialogMessage(PropertyDlg.hDialog,msg));
|
|
||||||
};
|
|
||||||
HBITMAP hbmMouse;
|
|
||||||
HBITMAP hbmMouse2;
|
|
||||||
HBITMAP hbmCursor;
|
|
||||||
HBITMAP hbmCursor2;
|
|
||||||
HBITMAP hbmBrush;
|
|
||||||
HBITMAP hbmBrush2;
|
|
||||||
HBITMAP hbmPlay;
|
|
||||||
HBITMAP hbmPlay2;
|
|
||||||
HBITMAP hbmHalt;
|
|
||||||
HBITMAP hbmHalt2;
|
|
||||||
friend INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
#elif defined(WITH_DEVELOPER_MODE)
|
|
||||||
virtual GtkWidget* InitGUI();
|
|
||||||
|
|
||||||
GdkCursor* cursorDefault;
|
|
||||||
GdkCursor* cursorWait;
|
|
||||||
|
|
||||||
GtkWidget* txtLog;
|
|
||||||
GtkWidget* txtScript;
|
|
||||||
GtkWidget* btnPlay;
|
|
||||||
GtkWidget* btnHalt;
|
|
||||||
GtkWidget* btnModePlay;
|
|
||||||
GtkWidget* btnModeEdit;
|
|
||||||
GtkWidget* btnModeDraw;
|
|
||||||
|
|
||||||
GtkWidget* menuBar;
|
|
||||||
GtkWidget* itemNet;
|
|
||||||
|
|
||||||
GtkWidget* menuViewport;
|
|
||||||
GtkWidget* menuPlayer;
|
|
||||||
|
|
||||||
GtkWidget* fileOpen;
|
|
||||||
GtkWidget* fileOpenWithPlayers;
|
|
||||||
GtkWidget* fileSave;
|
|
||||||
GtkWidget* fileSaveAs;
|
|
||||||
GtkWidget* fileSaveGame;
|
|
||||||
GtkWidget* fileSaveGameAs;
|
|
||||||
GtkWidget* fileRecord;
|
|
||||||
GtkWidget* fileClose;
|
|
||||||
GtkWidget* fileQuit;
|
|
||||||
|
|
||||||
GtkWidget* compScript;
|
|
||||||
GtkWidget* compTitle;
|
|
||||||
GtkWidget* compInfo;
|
|
||||||
GtkWidget* compObjects;
|
|
||||||
|
|
||||||
GtkWidget* plrJoin;
|
|
||||||
|
|
||||||
GtkWidget* viewNew;
|
|
||||||
|
|
||||||
GtkWidget* helpAbout;
|
|
||||||
|
|
||||||
GtkWidget* lblCursor;
|
|
||||||
GtkWidget* lblFrame;
|
|
||||||
GtkWidget* lblScript;
|
|
||||||
GtkWidget* lblTime;
|
|
||||||
|
|
||||||
gulong handlerPlay;
|
|
||||||
gulong handlerHalt;
|
|
||||||
gulong handlerModePlay;
|
|
||||||
gulong handlerModeEdit;
|
|
||||||
gulong handlerModeDraw;
|
|
||||||
|
|
||||||
static void OnScriptEntry(GtkWidget* entry, gpointer data);
|
|
||||||
static void OnPlay(GtkWidget* button, gpointer data);
|
|
||||||
static void OnHalt(GtkWidget* button, gpointer data);
|
|
||||||
static void OnModePlay(GtkWidget* button, gpointer data);
|
|
||||||
static void OnModeEdit(GtkWidget* button, gpointer data);
|
|
||||||
static void OnModeDraw(GtkWidget* button, gpointer data);
|
|
||||||
|
|
||||||
static void OnFileOpen(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileOpenWPlrs(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileSave(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileSaveAs(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileSaveGame(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileSaveGameAs(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileRecord(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileClose(GtkWidget* item, gpointer data);
|
|
||||||
static void OnFileQuit(GtkWidget* item, gpointer data);
|
|
||||||
|
|
||||||
static void OnCompObjects(GtkWidget* item, gpointer data);
|
|
||||||
static void OnCompScript(GtkWidget* item, gpointer data);
|
|
||||||
static void OnCompTitle(GtkWidget* item, gpointer data);
|
|
||||||
static void OnCompInfo(GtkWidget* item, gpointer data);
|
|
||||||
|
|
||||||
static void OnPlrJoin(GtkWidget* item, gpointer data);
|
|
||||||
static void OnPlrQuit(GtkWidget* item, gpointer data);
|
|
||||||
static void OnViewNew(GtkWidget* item, gpointer data);
|
|
||||||
static void OnViewNewPlr(GtkWidget* item, gpointer data);
|
|
||||||
static void OnHelpAbout(GtkWidget* item, gpointer data);
|
|
||||||
|
|
||||||
static void OnNetClient(GtkWidget* item, gpointer data);
|
|
||||||
#elif defined(USE_X11) && !defined(WITH_DEVELOPER_MODE)
|
|
||||||
virtual void HandleMessage (XEvent &);
|
virtual void HandleMessage (XEvent &);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
* OpenClonk, http://www.openclonk.org
|
||||||
|
*
|
||||||
|
* Portions might be copyrighted by other authors who have contributed
|
||||||
|
* to OpenClonk.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
* See isc_license.txt for full license and disclaimer.
|
||||||
|
*
|
||||||
|
* "Clonk" is a registered trademark of Matthes Bender.
|
||||||
|
* See clonk_trademark_license.txt for full license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef C4CONSOLEGUI_INC
|
||||||
|
#define C4CONSOLEGUI_INC
|
||||||
|
|
||||||
|
#include "C4Application.h"
|
||||||
|
#include "C4Player.h"
|
||||||
|
#include "C4GameControl.h"
|
||||||
|
#include "StdBuf.h"
|
||||||
|
|
||||||
|
#ifdef WITH_DEVELOPER_MODE
|
||||||
|
#include <StdGtkWindow.h>
|
||||||
|
typedef CStdGtkWindow C4ConsoleBase;
|
||||||
|
#else
|
||||||
|
typedef CStdWindow C4ConsoleBase;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace OpenFileFlags
|
||||||
|
{
|
||||||
|
const DWORD OFN_HIDEREADONLY = 1 << 0;
|
||||||
|
const DWORD OFN_OVERWRITEPROMPT = 1 << 1;
|
||||||
|
const DWORD OFN_FILEMUSTEXIST = 1 << 2;
|
||||||
|
const DWORD OFN_ALLOWMULTISELECT = 1 << 3;
|
||||||
|
|
||||||
|
const DWORD OFN_EXPLORER = 0; // ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
// Separate class containing GUI code for C4Console while C4Console itself only contains functionality
|
||||||
|
class C4ConsoleGUI: public C4ConsoleBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
static const char *LIST_DIVIDER;
|
||||||
|
|
||||||
|
template<class T> class InternalState
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
typedef class InternalState<T> Super;
|
||||||
|
private:
|
||||||
|
T *owner;
|
||||||
|
public:
|
||||||
|
InternalState(T *owner): owner(owner) {}
|
||||||
|
T *GetOwner() {return owner;}
|
||||||
|
};
|
||||||
|
|
||||||
|
enum InfoTextType
|
||||||
|
{
|
||||||
|
CONSOLE_FrameCounter,
|
||||||
|
CONSOLE_ScriptCounter,
|
||||||
|
CONSOLE_TimeFPS
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Stage
|
||||||
|
{
|
||||||
|
STAGE_Start,
|
||||||
|
STAGE_Intermediate,
|
||||||
|
STAGE_End,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Cursor
|
||||||
|
{
|
||||||
|
CURSOR_Normal,
|
||||||
|
CURSOR_Wait
|
||||||
|
};
|
||||||
|
|
||||||
|
class State;
|
||||||
|
|
||||||
|
private:
|
||||||
|
State *state;
|
||||||
|
public:
|
||||||
|
bool Editing;
|
||||||
|
bool fGameOpen;
|
||||||
|
|
||||||
|
C4ConsoleGUI();
|
||||||
|
~C4ConsoleGUI();
|
||||||
|
|
||||||
|
void SetCursor(Cursor cursor);
|
||||||
|
void RecordingEnabled();
|
||||||
|
void ShowAboutWithCopyright(StdStrBuf ©right);
|
||||||
|
bool UpdateCursorBar(const char *szCursor);
|
||||||
|
bool UpdateModeCtrls(int iMode);
|
||||||
|
void UpdateNetMenu(Stage stage);
|
||||||
|
void ClearNetMenu(Stage stage);
|
||||||
|
void AddNetMenuItemForPlayer(int32_t index, StdStrBuf &text);
|
||||||
|
void ClearInput();
|
||||||
|
void ClearPlayerMenu();
|
||||||
|
void SetInputFunctions(std::vector<char*> &functions);
|
||||||
|
|
||||||
|
CStdWindow* CreateConsoleWindow(CStdApp *application);
|
||||||
|
bool Out(const char* message);
|
||||||
|
bool ClearLog();
|
||||||
|
void DisplayInfoText(InfoTextType type, StdStrBuf& text);
|
||||||
|
void SetCaptionToFileName(const char* file_name);
|
||||||
|
void SetCaption(const char *caption);
|
||||||
|
bool FileSelect(char *sFilename, int iSize, const char * szFilter, DWORD dwFlags, bool fSave);
|
||||||
|
void AddMenuItemForPlayer(C4Player *player, StdStrBuf& player_text);
|
||||||
|
void AddKickPlayerMenuItem(C4Player *player, StdStrBuf& player_text, bool enabled);
|
||||||
|
void ClearViewportMenu();
|
||||||
|
bool Message(const char *message, bool query);
|
||||||
|
|
||||||
|
void EnableControls(bool fEnable)
|
||||||
|
{
|
||||||
|
if (!Active) return;
|
||||||
|
// disable Editing if no input allowed
|
||||||
|
Editing &= !::Control.NoInput();
|
||||||
|
DoEnableControls(fEnable);
|
||||||
|
}
|
||||||
|
void DoEnableControls(bool fEnable);
|
||||||
|
|
||||||
|
bool UpdateHaltCtrls(bool fHalt)
|
||||||
|
{
|
||||||
|
if (!Active)
|
||||||
|
return false;
|
||||||
|
DoUpdateHaltCtrls(fHalt);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool DoUpdateHaltCtrls(bool fHalt);
|
||||||
|
|
||||||
|
bool PropertyDlgOpen(class C4PropertyDlg *dlg);
|
||||||
|
void PropertyDlgUpdate(class C4PropertyDlg *dlg, StdStrBuf &text);
|
||||||
|
void PropertyDlgSetFunctions(C4PropertyDlg *dlg, std::vector<char*> &functions);
|
||||||
|
|
||||||
|
bool ToolsDlgOpen(class C4ToolsDlg *dlg);
|
||||||
|
void ToolsDlgInitMaterialCtrls(class C4ToolsDlg *dlg);
|
||||||
|
void ToolsDlgSetTexture(class C4ToolsDlg *dlg, const char *texture);
|
||||||
|
void ToolsDlgSetMaterial(class C4ToolsDlg *dlg, const char *material);
|
||||||
|
void ToolsDlgEnableControls(C4ToolsDlg *dlg);
|
||||||
|
void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture);
|
||||||
|
void ToolsDlgSelectMaterial(C4ToolsDlg *dlg, const char *material);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
void Win32KeepDialogsFloating(HWND hwnd = 0);
|
||||||
|
virtual bool Win32DialogMessageHandling(MSG *msg);
|
||||||
|
#endif
|
||||||
|
#ifdef WITH_DEVELOPER_MODE
|
||||||
|
virtual GtkWidget* InitGUI();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void ClearDlg(void *dlg);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* OpenClonk, http://www.openclonk.org
|
||||||
|
*
|
||||||
|
* Portions might be copyrighted by other authors who have contributed
|
||||||
|
* to OpenClonk.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
* See isc_license.txt for full license and disclaimer.
|
||||||
|
*
|
||||||
|
* "Clonk" is a registered trademark of Matthes Bender.
|
||||||
|
* See clonk_trademark_license.txt for full license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// To be directly included by platform-specific implementations
|
||||||
|
|
||||||
|
#include <C4Include.h>
|
||||||
|
|
||||||
|
#ifdef CONSOLEGUICOMMONINCLUDE
|
||||||
|
|
||||||
|
C4ConsoleGUI::C4ConsoleGUI()
|
||||||
|
{
|
||||||
|
state = new C4ConsoleGUI::State(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
C4ConsoleGUI::~C4ConsoleGUI() {delete state;}
|
||||||
|
|
||||||
|
void C4ConsoleGUI::SetCaption(const char *caption)
|
||||||
|
{
|
||||||
|
if (!Active) return;
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Sorry, the window caption needs to be constant so
|
||||||
|
// the window can be found using FindWindow
|
||||||
|
SetTitle(C4ENGINECAPTION);
|
||||||
|
#else
|
||||||
|
SetTitle(caption);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEFINE_STANDARD_DLG_METHODS(cls)\
|
||||||
|
cls::cls()\
|
||||||
|
{\
|
||||||
|
state = new cls::State(this);\
|
||||||
|
Default();\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
cls::~cls()\
|
||||||
|
{\
|
||||||
|
Clear();\
|
||||||
|
delete state;\
|
||||||
|
}\
|
||||||
|
|
||||||
|
DEFINE_STANDARD_DLG_METHODS(C4ToolsDlg)
|
||||||
|
|
||||||
|
void C4ToolsDlg::Clear()
|
||||||
|
{
|
||||||
|
state->Clear();
|
||||||
|
Console.ClearDlg(this);
|
||||||
|
Active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void C4ToolsDlg::Default()
|
||||||
|
{
|
||||||
|
state->Default();
|
||||||
|
Active = false;
|
||||||
|
Tool = SelectedTool = C4TLS_Brush;
|
||||||
|
Grade = C4TLS_GradeDefault;
|
||||||
|
ModeIFT = true;
|
||||||
|
SCopy("Earth",Material);
|
||||||
|
SCopy("earth",Texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_STANDARD_DLG_METHODS(C4PropertyDlg)
|
||||||
|
|
||||||
|
void C4PropertyDlg::Default()
|
||||||
|
{
|
||||||
|
state->Default();
|
||||||
|
Active = false;
|
||||||
|
//idSelectedDef=C4ID::None;
|
||||||
|
Selection.Default();
|
||||||
|
}
|
||||||
|
|
||||||
|
void C4PropertyDlg::Clear()
|
||||||
|
{
|
||||||
|
state->Clear();
|
||||||
|
Selection.Clear();
|
||||||
|
Console.ClearDlg(this);
|
||||||
|
Active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *C4ConsoleGUI::LIST_DIVIDER = "divid0r";
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,13 @@
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const DWORD OFN_HIDEREADONLY = 1 << 0;
|
||||||
|
const DWORD OFN_OVERWRITEPROMPT = 1 << 1;
|
||||||
|
const DWORD OFN_FILEMUSTEXIST = 1 << 2;
|
||||||
|
const DWORD OFN_ALLOWMULTISELECT = 1 << 3;
|
||||||
|
|
||||||
|
const DWORD OFN_EXPLORER = 0; // ignored
|
||||||
|
}
|
||||||
|
#ifdef USE_X11
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#endif
|
|
@ -36,127 +36,9 @@
|
||||||
|
|
||||||
#include <StdRegistry.h>
|
#include <StdRegistry.h>
|
||||||
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
# include <C4DevmodeDlg.h>
|
|
||||||
# include <C4Language.h>
|
|
||||||
|
|
||||||
# include <gtk/gtk.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
INT_PTR CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
switch (Msg)
|
|
||||||
{
|
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
case WM_CLOSE:
|
|
||||||
Console.PropertyDlg.Clear();
|
|
||||||
break;
|
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
case WM_DESTROY:
|
|
||||||
StoreWindowPosition(hDlg, "Property", Config.GetSubkeyPath("Console"), false);
|
|
||||||
break;
|
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0);
|
|
||||||
return true;
|
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
case WM_COMMAND:
|
|
||||||
// Evaluate command
|
|
||||||
switch (LOWORD(wParam))
|
|
||||||
{
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
case IDOK:
|
|
||||||
// IDC_COMBOINPUT to Console.EditCursor.In()
|
|
||||||
char buffer[16000];
|
|
||||||
GetDlgItemText(hDlg,IDC_COMBOINPUT,buffer,16000);
|
|
||||||
if (buffer[0])
|
|
||||||
Console.EditCursor.In(buffer);
|
|
||||||
return true;
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
case IDC_BUTTONRELOADDEF:
|
|
||||||
Game.ReloadDef( Console.PropertyDlg.idSelectedDef );
|
|
||||||
return true;
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
//-----------------------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
C4PropertyDlg::C4PropertyDlg()
|
|
||||||
{
|
|
||||||
Default();
|
|
||||||
}
|
|
||||||
|
|
||||||
C4PropertyDlg::~C4PropertyDlg()
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
if (vbox != NULL)
|
|
||||||
{
|
|
||||||
g_signal_handler_disconnect(G_OBJECT(C4DevmodeDlg::GetWindow()), handlerHide);
|
|
||||||
C4DevmodeDlg::RemovePage(vbox);
|
|
||||||
vbox = NULL;
|
|
||||||
}
|
|
||||||
#endif // WITH_DEVELOPER_MODE
|
|
||||||
}
|
|
||||||
|
|
||||||
bool C4PropertyDlg::Open()
|
bool C4PropertyDlg::Open()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
Console.PropertyDlgOpen(this);
|
||||||
if (hDialog) return true;
|
|
||||||
hDialog = CreateDialog(Application.GetInstance(),
|
|
||||||
MAKEINTRESOURCE(IDD_PROPERTIES),
|
|
||||||
Console.hWindow,
|
|
||||||
(DLGPROC) PropertyDlgProc);
|
|
||||||
if (!hDialog) return false;
|
|
||||||
// Set text
|
|
||||||
SetWindowText(hDialog,LoadResStr("IDS_DLG_PROPERTIES"));
|
|
||||||
// Enable controls
|
|
||||||
EnableWindow( GetDlgItem(hDialog,IDOK), Console.Editing );
|
|
||||||
EnableWindow( GetDlgItem(hDialog,IDC_COMBOINPUT), Console.Editing );
|
|
||||||
EnableWindow( GetDlgItem(hDialog,IDC_BUTTONRELOADDEF), Console.Editing );
|
|
||||||
// Show window
|
|
||||||
RestoreWindowPosition(hDialog, "Property", Config.GetSubkeyPath("Console"));
|
|
||||||
SetWindowPos(hDialog,Console.hWindow,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);
|
|
||||||
ShowWindow(hDialog,SW_SHOWNOACTIVATE);
|
|
||||||
#else // _WIN32
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
if (vbox == NULL)
|
|
||||||
{
|
|
||||||
vbox = gtk_vbox_new(false, 6);
|
|
||||||
|
|
||||||
GtkWidget* scrolled_wnd = gtk_scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_wnd), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
||||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_wnd), GTK_SHADOW_IN);
|
|
||||||
|
|
||||||
textview = gtk_text_view_new();
|
|
||||||
entry = gtk_entry_new();
|
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(scrolled_wnd), textview);
|
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), scrolled_wnd, true, true, 0);
|
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), entry, false, false, 0);
|
|
||||||
|
|
||||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), false);
|
|
||||||
gtk_widget_set_sensitive(entry, Console.Editing);
|
|
||||||
|
|
||||||
gtk_widget_show_all(vbox);
|
|
||||||
|
|
||||||
C4DevmodeDlg::AddPage(vbox, GTK_WINDOW(Console.window), LoadResStr("IDS_DLG_PROPERTIES"));
|
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(OnScriptActivate), this);
|
|
||||||
|
|
||||||
handlerHide = g_signal_connect(G_OBJECT(C4DevmodeDlg::GetWindow()), "hide", G_CALLBACK(OnWindowHide), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
C4DevmodeDlg::SwitchPage(vbox);
|
|
||||||
#endif // WITH_DEVELOPER_MODE
|
|
||||||
#endif // _WIN32
|
|
||||||
Active = true;
|
Active = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -239,135 +121,41 @@ bool C4PropertyDlg::Update()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Update info edit control
|
// Update info edit control
|
||||||
#ifdef _WIN32
|
Console.PropertyDlgUpdate(this, Output);
|
||||||
int iLine = SendDlgItemMessage(hDialog,IDC_EDITOUTPUT,EM_GETFIRSTVISIBLELINE,(WPARAM)0,(LPARAM)0);
|
|
||||||
SetDlgItemText(hDialog,IDC_EDITOUTPUT,Output.getData());
|
|
||||||
SendDlgItemMessage(hDialog,IDC_EDITOUTPUT,EM_LINESCROLL,(WPARAM)0,(LPARAM)iLine);
|
|
||||||
UpdateWindow(GetDlgItem(hDialog,IDC_EDITOUTPUT));
|
|
||||||
#else
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
|
|
||||||
gtk_text_buffer_set_text(buffer, Output.getData(), -1);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4PropertyDlg::Default()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
hDialog=NULL;
|
|
||||||
#else
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
vbox = NULL;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Active = false;
|
|
||||||
idSelectedDef=C4ID::None;
|
|
||||||
Selection.Default();
|
|
||||||
}
|
|
||||||
|
|
||||||
void C4PropertyDlg::Clear()
|
|
||||||
{
|
|
||||||
Selection.Clear();
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (hDialog) DestroyWindow(hDialog); hDialog=NULL;
|
|
||||||
#else
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
//if(vbox != NULL)
|
|
||||||
// C4DevmodeDlg::SwitchPage(NULL);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void C4PropertyDlg::UpdateInputCtrl(C4Object *pObj)
|
void C4PropertyDlg::UpdateInputCtrl(C4Object *pObj)
|
||||||
{
|
{
|
||||||
int cnt;
|
|
||||||
#ifdef _WIN32
|
|
||||||
HWND hCombo = GetDlgItem(hDialog,IDC_COMBOINPUT);
|
|
||||||
// Remember old window text
|
|
||||||
char szLastText[500+1];
|
|
||||||
GetWindowText(hCombo,szLastText,500);
|
|
||||||
// Clear
|
|
||||||
SendMessage(hCombo,CB_RESETCONTENT,0,0);
|
|
||||||
#else // _WIN32
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
|
|
||||||
GtkEntryCompletion* completion = gtk_entry_get_completion(GTK_ENTRY(entry));
|
|
||||||
GtkListStore* store;
|
|
||||||
|
|
||||||
// Uncouple list store from completion so that the completion is not
|
|
||||||
// notified for every row we are going to insert. This enhances
|
|
||||||
// performance significantly.
|
|
||||||
if (!completion)
|
|
||||||
{
|
|
||||||
completion = gtk_entry_completion_new();
|
|
||||||
store = gtk_list_store_new(1, G_TYPE_STRING);
|
|
||||||
|
|
||||||
gtk_entry_completion_set_text_column(completion, 0);
|
|
||||||
gtk_entry_set_completion(GTK_ENTRY(entry), completion);
|
|
||||||
g_object_unref(G_OBJECT(completion));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
store = GTK_LIST_STORE(gtk_entry_completion_get_model(completion));
|
|
||||||
g_object_ref(G_OBJECT(store));
|
|
||||||
gtk_entry_completion_set_model(completion, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gtk_list_store_clear(store);
|
|
||||||
#endif // WITH_DEVELOPER_MODE
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
// add global and standard functions
|
// add global and standard functions
|
||||||
|
std::vector<char*> functions;
|
||||||
for (C4AulFunc *pFn = ::ScriptEngine.GetFirstFunc(); pFn; pFn = ::ScriptEngine.GetNextFunc(pFn))
|
for (C4AulFunc *pFn = ::ScriptEngine.GetFirstFunc(); pFn; pFn = ::ScriptEngine.GetNextFunc(pFn))
|
||||||
|
{
|
||||||
if (pFn->GetPublic())
|
if (pFn->GetPublic())
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
functions.push_back(pFn->Name);
|
||||||
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)pFn->Name);
|
|
||||||
#else
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
gtk_list_store_append(store, &iter);
|
|
||||||
gtk_list_store_set(store, &iter, 0, pFn->Name, -1);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Add object script functions
|
// Add object script functions
|
||||||
#ifdef _WIN32
|
|
||||||
bool fDivider = false;
|
bool fDivider = false;
|
||||||
#endif
|
|
||||||
C4AulScriptFunc *pRef;
|
C4AulScriptFunc *pRef;
|
||||||
// Object script available
|
// Object script available
|
||||||
if (pObj && pObj->Def)
|
if (pObj && pObj->Def)
|
||||||
|
{
|
||||||
// Scan all functions
|
// Scan all functions
|
||||||
for (cnt=0; (pRef=pObj->Def->Script.GetSFunc(cnt)); cnt++)
|
for (int cnt=0; (pRef=pObj->Def->Script.GetSFunc(cnt)); cnt++)
|
||||||
|
{
|
||||||
// Public functions only
|
// Public functions only
|
||||||
if ((pRef->Access=AA_PUBLIC))
|
if ((pRef->Access=AA_PUBLIC))
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
// Insert divider if necessary
|
// Insert divider if necessary
|
||||||
if (!fDivider) { SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)"----------"); fDivider=true; }
|
if (!fDivider) { functions.push_back((char*)C4ConsoleGUI::LIST_DIVIDER); fDivider=true; }
|
||||||
#endif
|
|
||||||
// Add function
|
// Add function
|
||||||
#ifdef _WIN32
|
functions.push_back(pRef->Name);
|
||||||
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)pRef->Name);
|
|
||||||
#else
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
gtk_list_store_append(store, &iter);
|
|
||||||
gtk_list_store_set(store, &iter, 0, pRef->Name, -1);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#ifdef _WIN32
|
}
|
||||||
// Restore old text
|
Console.PropertyDlgSetFunctions(this, functions);
|
||||||
SetWindowText(hCombo,szLastText);
|
|
||||||
#elif defined(WITH_DEVELOPER_MODE)
|
|
||||||
// Reassociate list store with completion
|
|
||||||
gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4PropertyDlg::Execute()
|
void C4PropertyDlg::Execute()
|
||||||
|
@ -379,24 +167,3 @@ void C4PropertyDlg::ClearPointers(C4Object *pObj)
|
||||||
{
|
{
|
||||||
Selection.ClearPointers(pObj);
|
Selection.ClearPointers(pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
// GTK+ callbacks
|
|
||||||
void C4PropertyDlg::OnScriptActivate(GtkWidget* widget, gpointer data)
|
|
||||||
{
|
|
||||||
const gchar* text = gtk_entry_get_text(GTK_ENTRY(widget));
|
|
||||||
if (text && text[0])
|
|
||||||
Console.EditCursor.In(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void C4PropertyDlg::OnWindowHide(GtkWidget* widget, gpointer user_data)
|
|
||||||
{
|
|
||||||
static_cast<C4PropertyDlg*>(user_data)->Active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*void C4PropertyDlg::OnDestroy(GtkWidget* widget, gpointer data)
|
|
||||||
{
|
|
||||||
static_cast<C4PropertyDlg*>(data)->window = NULL;
|
|
||||||
static_cast<C4PropertyDlg*>(data)->Active = false;
|
|
||||||
}*/
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -26,12 +26,14 @@
|
||||||
|
|
||||||
#include "C4ObjectList.h"
|
#include "C4ObjectList.h"
|
||||||
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
#include "C4ConsoleGUI.h"
|
||||||
# include <gtk/gtk.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class C4PropertyDlg
|
class C4PropertyDlg
|
||||||
{
|
{
|
||||||
|
friend class C4ConsoleGUI;
|
||||||
|
private:
|
||||||
|
class State;
|
||||||
|
State *state;
|
||||||
public:
|
public:
|
||||||
C4PropertyDlg();
|
C4PropertyDlg();
|
||||||
~C4PropertyDlg();
|
~C4PropertyDlg();
|
||||||
|
@ -44,24 +46,7 @@ public:
|
||||||
bool Update();
|
bool Update();
|
||||||
bool Update(C4ObjectList &rSelection);
|
bool Update(C4ObjectList &rSelection);
|
||||||
bool Active;
|
bool Active;
|
||||||
#ifdef _WIN32
|
public: // ToolsDlg fields are public as well...
|
||||||
HWND hDialog;
|
|
||||||
friend INT_PTR CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
#else
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
// GtkWidget* window;
|
|
||||||
GtkWidget* vbox;
|
|
||||||
GtkWidget* textview;
|
|
||||||
GtkWidget* entry;
|
|
||||||
|
|
||||||
gulong handlerHide;
|
|
||||||
|
|
||||||
static void OnScriptActivate(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnWindowHide(GtkWidget* widget, gpointer data);
|
|
||||||
// static void OnDestroy(GtkWidget* widget, gpointer data);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
protected:
|
|
||||||
C4ID idSelectedDef;
|
C4ID idSelectedDef;
|
||||||
C4ObjectList Selection;
|
C4ObjectList Selection;
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,118 +29,45 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "C4Constants.h"
|
#include "C4Constants.h"
|
||||||
|
#include "C4ConsoleGUI.h"
|
||||||
|
|
||||||
const int32_t C4TLS_Brush = 0,
|
const int32_t
|
||||||
C4TLS_Line = 1,
|
C4TLS_Brush = 0,
|
||||||
C4TLS_Rect = 2,
|
C4TLS_Line = 1,
|
||||||
C4TLS_Fill = 3,
|
C4TLS_Rect = 2,
|
||||||
C4TLS_Picker = 4;
|
C4TLS_Fill = 3,
|
||||||
|
C4TLS_Picker = 4;
|
||||||
|
|
||||||
const int32_t C4TLS_GradeMax = 50,
|
const int32_t
|
||||||
C4TLS_GradeMin = 1,
|
C4TLS_GradeMax = 50,
|
||||||
C4TLS_GradeDefault = 5;
|
C4TLS_GradeMin = 1,
|
||||||
|
C4TLS_GradeDefault = 5;
|
||||||
|
|
||||||
#define C4TLS_MatSky "Sky"
|
#define C4TLS_MatSky "Sky"
|
||||||
|
|
||||||
class C4ToolsDlg
|
class C4ToolsDlg
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
friend class C4ConsoleGUI;
|
||||||
friend INT_PTR CALLBACK ToolsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
private:
|
||||||
#endif
|
class State;
|
||||||
|
State *state;
|
||||||
public:
|
public:
|
||||||
C4ToolsDlg();
|
C4ToolsDlg();
|
||||||
~C4ToolsDlg();
|
~C4ToolsDlg();
|
||||||
public:
|
public:
|
||||||
bool Active;
|
bool Active;
|
||||||
#ifdef _WIN32
|
|
||||||
HWND hDialog;
|
|
||||||
#ifdef USE_GL
|
|
||||||
class CStdGLCtx *pGLCtx; // rendering context for OpenGL
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifdef WITH_DEVELOPER_MODE
|
|
||||||
GtkWidget* hbox;
|
|
||||||
|
|
||||||
GtkWidget* brush;
|
|
||||||
GtkWidget* line;
|
|
||||||
GtkWidget* rect;
|
|
||||||
GtkWidget* fill;
|
|
||||||
GtkWidget* picker;
|
|
||||||
|
|
||||||
GtkWidget* landscape_dynamic;
|
|
||||||
GtkWidget* landscape_static;
|
|
||||||
GtkWidget* landscape_exact;
|
|
||||||
|
|
||||||
GtkWidget* preview;
|
|
||||||
GtkWidget* scale;
|
|
||||||
|
|
||||||
GtkWidget* ift;
|
|
||||||
GtkWidget* no_ift;
|
|
||||||
|
|
||||||
GtkWidget* materials;
|
|
||||||
GtkWidget* textures;
|
|
||||||
|
|
||||||
gulong handlerBrush;
|
|
||||||
gulong handlerLine;
|
|
||||||
gulong handlerRect;
|
|
||||||
gulong handlerFill;
|
|
||||||
gulong handlerPicker;
|
|
||||||
|
|
||||||
gulong handlerDynamic;
|
|
||||||
gulong handlerStatic;
|
|
||||||
gulong handlerExact;
|
|
||||||
|
|
||||||
gulong handlerIft;
|
|
||||||
gulong handlerNoIft;
|
|
||||||
|
|
||||||
gulong handlerMaterials;
|
|
||||||
gulong handlerTextures;
|
|
||||||
gulong handlerScale;
|
|
||||||
|
|
||||||
gulong handlerHide;
|
|
||||||
|
|
||||||
//static void OnDestroy(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonModeDynamic(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonModeStatic(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonModeExact(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonBrush(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonLine(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonRect(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonFill(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonPicker(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonIft(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnButtonNoIft(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnComboMaterial(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnComboTexture(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnGrade(GtkWidget* widget, gpointer data);
|
|
||||||
static void OnWindowHide(GtkWidget* widget, gpointer data);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
int32_t Tool, SelectedTool;
|
int32_t Tool, SelectedTool;
|
||||||
int32_t Grade;
|
int32_t Grade;
|
||||||
bool ModeIFT;
|
bool ModeIFT;
|
||||||
char Material[C4M_MaxName+1];
|
char Material[C4M_MaxName+1];
|
||||||
char Texture[C4M_MaxName+1];
|
char Texture[C4M_MaxName+1];
|
||||||
protected:
|
|
||||||
#ifdef _WIN32
|
|
||||||
HBITMAP hbmBrush,hbmBrush2;
|
|
||||||
HBITMAP hbmLine,hbmLine2;
|
|
||||||
HBITMAP hbmRect,hbmRect2;
|
|
||||||
HBITMAP hbmFill,hbmFill2;
|
|
||||||
HBITMAP hbmPicker,hbmPicker2;
|
|
||||||
HBITMAP hbmIFT;
|
|
||||||
HBITMAP hbmNoIFT;
|
|
||||||
HBITMAP hbmDynamic;
|
|
||||||
HBITMAP hbmStatic;
|
|
||||||
HBITMAP hbmExact;
|
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
void Default();
|
void Default();
|
||||||
void Clear();
|
void Clear();
|
||||||
bool PopTextures();
|
bool PopTextures();
|
||||||
bool PopMaterial();
|
bool PopMaterial();
|
||||||
bool ChangeGrade(int32_t iChange);
|
bool ChangeGrade(int32_t iChange);
|
||||||
void UpdatePreview();
|
void NeedPreviewUpdate();
|
||||||
bool Open();
|
bool Open();
|
||||||
bool SetGrade(int32_t iGrade);
|
bool SetGrade(int32_t iGrade);
|
||||||
bool SetTool(int32_t iTool, bool fTemp);
|
bool SetTool(int32_t iTool, bool fTemp);
|
||||||
|
|
|
@ -414,6 +414,7 @@ namespace C4GUI
|
||||||
virtual bool IsOwnPtrElement() { return false; } // if true is returned, item will not be deleted when container is cleared
|
virtual bool IsOwnPtrElement() { return false; } // if true is returned, item will not be deleted when container is cleared
|
||||||
virtual bool IsExternalDrawDialog() { return false; }
|
virtual bool IsExternalDrawDialog() { return false; }
|
||||||
virtual bool IsMenu() { return false; }
|
virtual bool IsMenu() { return false; }
|
||||||
|
virtual class DialogWindow* GetDialogWindow() { return NULL; } // return DialogWindow if this element is a dialog
|
||||||
|
|
||||||
// for listbox-selection by character input
|
// for listbox-selection by character input
|
||||||
virtual bool CheckNameHotkey(const char * c) { return false; }
|
virtual bool CheckNameHotkey(const char * c) { return false; }
|
||||||
|
@ -1937,16 +1938,21 @@ namespace C4GUI
|
||||||
friend class ComboBox_FillCB;
|
friend class ComboBox_FillCB;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Dialog;
|
||||||
|
|
||||||
// EM window class
|
// EM window class
|
||||||
class DialogWindow : public CStdWindow
|
class DialogWindow : public CStdWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Dialog* pDialog;
|
||||||
|
DialogWindow(): CStdWindow(), pDialog(NULL) {}
|
||||||
using CStdWindow::Init;
|
using CStdWindow::Init;
|
||||||
CStdWindow * Init(CStdApp * pApp, const char * Title, CStdWindow * pParent, const C4Rect &rcBounds, const char *szID);
|
CStdWindow * Init(CStdWindow::WindowKind windowKind, CStdApp * pApp, const char * Title, CStdWindow * pParent, const C4Rect &rcBounds, const char *szID);
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
#if defined(USE_X11)
|
#ifdef USE_X11
|
||||||
virtual void HandleMessage (XEvent &);
|
virtual void HandleMessage (XEvent &);
|
||||||
#endif
|
#endif
|
||||||
|
virtual void PerformUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
// information on how to draw dialog borders and face
|
// information on how to draw dialog borders and face
|
||||||
|
@ -1978,7 +1984,7 @@ namespace C4GUI
|
||||||
};
|
};
|
||||||
|
|
||||||
// a dialog
|
// a dialog
|
||||||
class Dialog : public Window
|
class Dialog: public Window
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
enum Fade { eFadeNone=0, eFadeOut, eFadeIn };
|
enum Fade { eFadeNone=0, eFadeOut, eFadeIn };
|
||||||
|
@ -2024,6 +2030,7 @@ namespace C4GUI
|
||||||
void SetFocus(Control *pCtrl, bool fByMouse);
|
void SetFocus(Control *pCtrl, bool fByMouse);
|
||||||
Control *GetFocus() { return pActiveCtrl; }
|
Control *GetFocus() { return pActiveCtrl; }
|
||||||
virtual Dialog *GetDlg() { return this; } // this is the dialog
|
virtual Dialog *GetDlg() { return this; } // this is the dialog
|
||||||
|
virtual DialogWindow* GetDialogWindow() { return pWindow; }
|
||||||
|
|
||||||
virtual bool CharIn(const char * c); // input: character key pressed - should return false for none-character-inputs (forward to focused control)
|
virtual bool CharIn(const char * c); // input: character key pressed - should return false for none-character-inputs (forward to focused control)
|
||||||
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam); // input: mouse. forwards to child controls
|
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam); // input: mouse. forwards to child controls
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
#define None Die_XLib_Die
|
#define None Die_XLib_Die
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
@ -190,7 +191,7 @@ namespace C4GUI
|
||||||
// DialogWindow
|
// DialogWindow
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
CStdWindow * DialogWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * pParent, const C4Rect &rcBounds, const char *szID)
|
CStdWindow * DialogWindow::Init(CStdWindow::WindowKind windowKind, CStdApp * pApp, const char * Title, CStdWindow * pParent, const C4Rect &rcBounds, const char *szID)
|
||||||
{
|
{
|
||||||
Active = true;
|
Active = true;
|
||||||
// calculate required size
|
// calculate required size
|
||||||
|
@ -311,18 +312,21 @@ namespace C4GUI
|
||||||
return !!RegisterClassEx(&WndClass);
|
return !!RegisterClassEx(&WndClass);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
CStdWindow * DialogWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * pParent, const C4Rect &rcBounds, const char *szID)
|
CStdWindow * DialogWindow::Init(CStdWindow::WindowKind windowKind, CStdApp * pApp, const char * Title, CStdWindow * pParent, const C4Rect &rcBounds, const char *szID)
|
||||||
{
|
{
|
||||||
if (CStdWindow::Init(pApp, Title, pParent, false))
|
CStdWindow *result;
|
||||||
|
if (CStdWindow::Init(windowKind, pApp, Title, pParent, false))
|
||||||
{
|
{
|
||||||
// update pos
|
// update pos
|
||||||
if (szID && *szID)
|
if (szID && *szID)
|
||||||
RestorePosition(FormatString("ConsoleGUI_%s", szID).getData(), Config.GetSubkeyPath("Console"), false);
|
RestorePosition(FormatString("ConsoleGUI_%s", szID).getData(), Config.GetSubkeyPath("Console"), false);
|
||||||
else
|
else
|
||||||
SetSize(rcBounds.Wdt, rcBounds.Hgt);
|
SetSize(rcBounds.Wdt, rcBounds.Hgt);
|
||||||
return this;
|
result = this;
|
||||||
}
|
}
|
||||||
return NULL;
|
else
|
||||||
|
result = NULL;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
void DialogWindow::HandleMessage (XEvent &e)
|
void DialogWindow::HandleMessage (XEvent &e)
|
||||||
|
@ -427,6 +431,26 @@ namespace C4GUI
|
||||||
#endif
|
#endif
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
void DialogWindow::PerformUpdate()
|
||||||
|
{
|
||||||
|
if (!pDialog)
|
||||||
|
return; // safety
|
||||||
|
RECT r;
|
||||||
|
GetSize(&r);
|
||||||
|
if (pSurface)
|
||||||
|
{
|
||||||
|
pSurface->Wdt = r.right;
|
||||||
|
pSurface->Hgt = r.bottom;
|
||||||
|
#ifdef USE_GL
|
||||||
|
pGL->PrepareRendering(pSurface);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
C4TargetFacet cgo;
|
||||||
|
cgo.Set(NULL, 0, 0, r.right, r.bottom, 0, 0);
|
||||||
|
pDialog->Draw(cgo);
|
||||||
|
}
|
||||||
|
|
||||||
void DialogWindow::Close()
|
void DialogWindow::Close()
|
||||||
{
|
{
|
||||||
// FIXME: Close the dialog of this window
|
// FIXME: Close the dialog of this window
|
||||||
|
@ -440,7 +464,7 @@ namespace C4GUI
|
||||||
if (pWindow) return true;
|
if (pWindow) return true;
|
||||||
// create it!
|
// create it!
|
||||||
pWindow = new DialogWindow();
|
pWindow = new DialogWindow();
|
||||||
if (!pWindow->Init(&Application, TitleString.getData(), &Console, rcBounds, GetID()))
|
if (!pWindow->Init(CStdWindow::W_GuiWindow, &Application, TitleString.getData(), &Console, rcBounds, GetID()))
|
||||||
{
|
{
|
||||||
delete pWindow;
|
delete pWindow;
|
||||||
pWindow = NULL;
|
pWindow = NULL;
|
||||||
|
@ -448,6 +472,7 @@ namespace C4GUI
|
||||||
}
|
}
|
||||||
// create rendering context
|
// create rendering context
|
||||||
pWindow->pSurface = new CSurface(&Application, pWindow);
|
pWindow->pSurface = new CSurface(&Application, pWindow);
|
||||||
|
pWindow->pDialog = this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ namespace
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
|
||||||
bool C4Viewport::DropFiles(HANDLE hDrop)
|
bool C4Viewport::DropFiles(HANDLE hDrop)
|
||||||
{
|
{
|
||||||
if (!Console.Editing) { Console.Message(LoadResStr("IDS_CNS_NONETEDIT")); return false; }
|
if (!Console.Editing) { Console.Message(LoadResStr("IDS_CNS_NONETEDIT")); return false; }
|
||||||
|
@ -771,7 +772,10 @@ void C4ViewportList::Execute(bool DrawBackground)
|
||||||
if (DrawBackground)
|
if (DrawBackground)
|
||||||
DrawFullscreenBackground();
|
DrawFullscreenBackground();
|
||||||
for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
|
for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
|
||||||
cvp->Execute();
|
{
|
||||||
|
if (cvp->GetWindow())
|
||||||
|
cvp->GetWindow()->RequestUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4ViewportList::DrawFullscreenBackground()
|
void C4ViewportList::DrawFullscreenBackground()
|
||||||
|
|
|
@ -94,6 +94,8 @@ protected:
|
||||||
void DrawPlayerInfo(C4TargetFacet &cgo);
|
void DrawPlayerInfo(C4TargetFacet &cgo);
|
||||||
void BlitOutput();
|
void BlitOutput();
|
||||||
void AdjustPosition();
|
void AdjustPosition();
|
||||||
|
public:
|
||||||
|
C4ViewportWindow* GetWindow() {return pWindow;}
|
||||||
bool UpdateOutputSize();
|
bool UpdateOutputSize();
|
||||||
bool ViewPositionByScrollBars();
|
bool ViewPositionByScrollBars();
|
||||||
bool ScrollBarsByViewPosition();
|
bool ScrollBarsByViewPosition();
|
||||||
|
|
|
@ -116,7 +116,7 @@ bool C4SoundEffect::Load(BYTE *pData, size_t iDataLen, bool fStatic, bool fRaw)
|
||||||
// Set usage time
|
// Set usage time
|
||||||
UsageTime=Game.Time;
|
UsageTime=Game.Time;
|
||||||
Static=fStatic;
|
Static=fStatic;
|
||||||
return pSample;
|
return !!pSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4SoundEffect::Execute()
|
void C4SoundEffect::Execute()
|
||||||
|
|
|
@ -148,10 +148,7 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
// posts a new WM_ACTIVATE to us, and so on, ultimately leading to a hang.
|
// posts a new WM_ACTIVATE to us, and so on, ultimately leading to a hang.
|
||||||
if (LOWORD(wParam) == WA_INACTIVE)
|
if (LOWORD(wParam) == WA_INACTIVE)
|
||||||
{
|
{
|
||||||
if (Console.PropertyDlg.hDialog)
|
Console.Win32KeepDialogsFloating();
|
||||||
SetWindowLongPtr(Console.PropertyDlg.hDialog, GWLP_HWNDPARENT, reinterpret_cast<LONG_PTR>(Console.hWindow));
|
|
||||||
if (Console.ToolsDlg.hDialog)
|
|
||||||
SetWindowLongPtr(Console.PropertyDlg.hDialog, GWLP_HWNDPARENT, reinterpret_cast<LONG_PTR>(Console.hWindow));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -159,10 +156,7 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
case WM_MOUSEACTIVATE:
|
case WM_MOUSEACTIVATE:
|
||||||
// WM_MOUSEACTIVATE is emitted when the user hovers over a window and pushes a mouse button.
|
// WM_MOUSEACTIVATE is emitted when the user hovers over a window and pushes a mouse button.
|
||||||
// Setting the window owner here avoids z-order flickering.
|
// Setting the window owner here avoids z-order flickering.
|
||||||
if (Console.PropertyDlg.hDialog)
|
Console.Win32KeepDialogsFloating(hwnd);
|
||||||
SetWindowLongPtr(Console.PropertyDlg.hDialog, GWLP_HWNDPARENT, reinterpret_cast<LONG_PTR>(hwnd));
|
|
||||||
if (Console.ToolsDlg.hDialog)
|
|
||||||
SetWindowLongPtr(Console.ToolsDlg.hDialog, GWLP_HWNDPARENT, reinterpret_cast<LONG_PTR>(hwnd));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//----------------------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -250,7 +244,7 @@ bool C4ViewportWindow::RegisterViewportClass(HINSTANCE hInst)
|
||||||
return fViewportClassRegistered = C4GUI::Dialog::RegisterWindowClass(hInst);
|
return fViewportClassRegistered = C4GUI::Dialog::RegisterWindowClass(hInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
CStdWindow * C4ViewportWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * pParent, bool)
|
CStdWindow * C4ViewportWindow::Init(CStdWindow::WindowKind windowKind, CStdApp * pApp, const char * Title, CStdWindow * pParent, bool)
|
||||||
{
|
{
|
||||||
Active = true;
|
Active = true;
|
||||||
// Create window
|
// Create window
|
||||||
|
@ -665,10 +659,12 @@ void C4ViewportWindow::OnHScrollStatic(GtkAdjustment* adjustment, gpointer user_
|
||||||
static_cast<C4ViewportWindow*>(user_data)->cvp->ViewPositionByScrollBars();
|
static_cast<C4ViewportWindow*>(user_data)->cvp->ViewPositionByScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // WITH_DEVELOPER_MODE
|
#endif // WITH_DEVELOPER_MODE
|
||||||
|
|
||||||
|
#if defined(USE_X11) && !defined(WITH_DEVELOPER_MODE)
|
||||||
bool C4Viewport::TogglePlayerLock() { return false; }
|
bool C4Viewport::TogglePlayerLock() { return false; }
|
||||||
bool C4Viewport::ScrollBarsByViewPosition() { return false; }
|
bool C4Viewport::ScrollBarsByViewPosition() { return false; }
|
||||||
#if defined(USE_X11)
|
|
||||||
void C4ViewportWindow::HandleMessage (XEvent & e)
|
void C4ViewportWindow::HandleMessage (XEvent & e)
|
||||||
{
|
{
|
||||||
switch (e.type)
|
switch (e.type)
|
||||||
|
@ -800,7 +796,15 @@ void C4ViewportWindow::HandleMessage (XEvent & e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_X11
|
#endif // USE_X11
|
||||||
#endif // WITH_DEVELOPER_MODE/_WIN32
|
|
||||||
|
void C4ViewportWindow::PerformUpdate()
|
||||||
|
{
|
||||||
|
if (cvp)
|
||||||
|
{
|
||||||
|
cvp->UpdateOutputSize();
|
||||||
|
cvp->Execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void C4ViewportWindow::Close()
|
void C4ViewportWindow::Close()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
C4Viewport * cvp;
|
C4Viewport * cvp;
|
||||||
C4ViewportWindow(C4Viewport * cvp): cvp(cvp) { }
|
C4ViewportWindow(C4Viewport * cvp): cvp(cvp) { }
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
virtual CStdWindow * Init(CStdApp * pApp, const char * Title, CStdWindow * pParent, bool);
|
virtual CStdWindow * Init(CStdWindow::WindowKind windowKind, CStdApp * pApp, const char * Title, CStdWindow * pParent, bool);
|
||||||
static bool RegisterViewportClass(HINSTANCE hInst);
|
static bool RegisterViewportClass(HINSTANCE hInst);
|
||||||
#elif defined(WITH_DEVELOPER_MODE)
|
#elif defined(WITH_DEVELOPER_MODE)
|
||||||
virtual GtkWidget* InitGUI();
|
virtual GtkWidget* InitGUI();
|
||||||
|
@ -70,6 +70,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
void EditCursorMove(int X, int Y, uint16_t);
|
void EditCursorMove(int X, int Y, uint16_t);
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
|
virtual void PerformUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
#define C4ViewportClassName "C4Viewport"
|
#define C4ViewportClassName "C4Viewport"
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* OpenClonk, http://www.openclonk.org
|
||||||
|
*
|
||||||
|
* Portions might be copyrighted by other authors who have contributed
|
||||||
|
* to OpenClonk.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
* See isc_license.txt for full license and disclaimer.
|
||||||
|
*
|
||||||
|
* "Clonk" is a registered trademark of Matthes Bender.
|
||||||
|
* See clonk_trademark_license.txt for full license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <C4Include.h>
|
||||||
|
#include "StdAppCommon.h"
|
||||||
|
|
||||||
|
void CStdApp::Run()
|
||||||
|
{
|
||||||
|
// Main message loop
|
||||||
|
while (!fQuitMsgReceived)
|
||||||
|
ScheduleProcs();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CStdApp::ScheduleProcs(int iTimeout)
|
||||||
|
{
|
||||||
|
// Always fail after quit message
|
||||||
|
if(fQuitMsgReceived)
|
||||||
|
return false;
|
||||||
|
#if defined(USE_SDL_MAINLOOP)
|
||||||
|
// Unfortunately, the SDL event loop needs to be polled
|
||||||
|
FlushMessages();
|
||||||
|
#endif
|
||||||
|
return StdScheduler::ScheduleProcs(iTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStdWindow::PerformUpdate()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* OpenClonk, http://www.openclonk.org
|
||||||
|
*
|
||||||
|
* Portions might be copyrighted by other authors who have contributed
|
||||||
|
* to OpenClonk.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
* See isc_license.txt for full license and disclaimer.
|
||||||
|
*
|
||||||
|
* "Clonk" is a registered trademark of Matthes Bender.
|
||||||
|
* See clonk_trademark_license.txt for full license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <StdWindow.h>
|
|
@ -205,3 +205,9 @@ GtkWidget* CStdGtkWindow::InitGUI()
|
||||||
{
|
{
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CStdWindow::RequestUpdate()
|
||||||
|
{
|
||||||
|
// just invoke directly
|
||||||
|
PerformUpdate();
|
||||||
|
}
|
||||||
|
|
|
@ -483,3 +483,9 @@ bool CStdApp::IsClipboardFull(bool fClipboard)
|
||||||
void CStdApp::ClearClipboard(bool fClipboard)
|
void CStdApp::ClearClipboard(bool fClipboard)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CStdWindow::RequestUpdate()
|
||||||
|
{
|
||||||
|
// just invoke directly
|
||||||
|
PerformUpdate();
|
||||||
|
}
|
|
@ -240,6 +240,13 @@ typedef struct _XDisplay Display;
|
||||||
|
|
||||||
class CStdWindow
|
class CStdWindow
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum WindowKind
|
||||||
|
{
|
||||||
|
W_GuiWindow,
|
||||||
|
W_Viewport,
|
||||||
|
W_Fullscreen
|
||||||
|
};
|
||||||
public:
|
public:
|
||||||
CStdWindow ();
|
CStdWindow ();
|
||||||
virtual ~CStdWindow ();
|
virtual ~CStdWindow ();
|
||||||
|
@ -253,7 +260,7 @@ public:
|
||||||
virtual void CharIn(const char * c) { }
|
virtual void CharIn(const char * c) { }
|
||||||
virtual CStdWindow * Init(CStdApp * pApp);
|
virtual CStdWindow * Init(CStdApp * pApp);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
virtual CStdWindow * Init(CStdApp * pApp, const char * Title, CStdWindow * pParent = 0, bool HideCursor = true);
|
virtual CStdWindow * Init(WindowKind windowKind, CStdApp * pApp, const char * Title, CStdWindow * pParent = 0, bool HideCursor = true);
|
||||||
#endif
|
#endif
|
||||||
bool StorePosition(const char *szWindowName, const char *szSubKey, bool fStoreSize = true);
|
bool StorePosition(const char *szWindowName, const char *szSubKey, bool fStoreSize = true);
|
||||||
bool RestorePosition(const char *szWindowName, const char *szSubKey, bool fHidden = false);
|
bool RestorePosition(const char *szWindowName, const char *szSubKey, bool fHidden = false);
|
||||||
|
@ -261,7 +268,7 @@ public:
|
||||||
void SetSize(unsigned int cx, unsigned int cy); // resize
|
void SetSize(unsigned int cx, unsigned int cy); // resize
|
||||||
void SetTitle(const char * Title);
|
void SetTitle(const char * Title);
|
||||||
void FlashWindow();
|
void FlashWindow();
|
||||||
protected:
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
public:
|
public:
|
||||||
HWND hWindow;
|
HWND hWindow;
|
||||||
|
@ -287,6 +294,12 @@ private:
|
||||||
protected:
|
protected:
|
||||||
virtual void HandleMessage(SDL_Event&) {}
|
virtual void HandleMessage(SDL_Event&) {}
|
||||||
#endif
|
#endif
|
||||||
|
public:
|
||||||
|
// request that this window be redrawn in the near future (including immediately)
|
||||||
|
virtual void RequestUpdate();
|
||||||
|
// Invokes actual drawing code - should not be called directly
|
||||||
|
virtual void PerformUpdate();
|
||||||
|
public:
|
||||||
friend class CStdDDraw;
|
friend class CStdDDraw;
|
||||||
friend class CStdGL;
|
friend class CStdGL;
|
||||||
friend class CStdGLCtx;
|
friend class CStdGLCtx;
|
||||||
|
@ -375,28 +388,13 @@ public:
|
||||||
virtual void Clear();
|
virtual void Clear();
|
||||||
|
|
||||||
bool Init(int argc, char * argv[]);
|
bool Init(int argc, char * argv[]);
|
||||||
void Run()
|
void Run();
|
||||||
{
|
|
||||||
// Main message loop
|
|
||||||
while (!fQuitMsgReceived)
|
|
||||||
ScheduleProcs();
|
|
||||||
}
|
|
||||||
virtual void Quit();
|
virtual void Quit();
|
||||||
|
|
||||||
bool GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, uint32_t iMonitor);
|
bool GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, uint32_t iMonitor);
|
||||||
bool SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int iColorDepth, unsigned int iMonitor, bool fFullScreen);
|
bool SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int iColorDepth, unsigned int iMonitor, bool fFullScreen);
|
||||||
void RestoreVideoMode();
|
void RestoreVideoMode();
|
||||||
bool ScheduleProcs(int iTimeout = -1)
|
bool ScheduleProcs(int iTimeout = -1);
|
||||||
{
|
|
||||||
// Always fail after quit message
|
|
||||||
if (fQuitMsgReceived)
|
|
||||||
return false;
|
|
||||||
#if defined(USE_SDL_MAINLOOP)
|
|
||||||
// Unfortunately, the SDL event loop needs to be polled
|
|
||||||
FlushMessages();
|
|
||||||
#endif
|
|
||||||
return StdScheduler::ScheduleProcs(iTimeout);
|
|
||||||
}
|
|
||||||
bool FlushMessages();
|
bool FlushMessages();
|
||||||
CStdWindow * pWindow;
|
CStdWindow * pWindow;
|
||||||
bool fQuitMsgReceived; // if true, a quit message has been received and the application should terminate
|
bool fQuitMsgReceived; // if true, a quit message has been received and the application should terminate
|
||||||
|
|
|
@ -60,10 +60,10 @@ CStdWindow::~CStdWindow ()
|
||||||
}
|
}
|
||||||
CStdWindow * CStdWindow::Init(CStdApp * pApp)
|
CStdWindow * CStdWindow::Init(CStdApp * pApp)
|
||||||
{
|
{
|
||||||
return Init(pApp, C4ENGINENAME);
|
return Init(CStdWindow::W_Viewport, pApp, C4ENGINENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
CStdWindow * CStdWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * pParent, bool HideCursor)
|
CStdWindow * CStdWindow::Init(CStdWindow::WindowKind windowKind, CStdApp * pApp, const char * Title, CStdWindow * pParent, bool HideCursor)
|
||||||
{
|
{
|
||||||
Active = true;
|
Active = true;
|
||||||
dpy = pApp->dpy;
|
dpy = pApp->dpy;
|
||||||
|
|
Loading…
Reference in New Issue