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
|
||||
.DS_Store
|
||||
._*
|
||||
xcode/build
|
||||
*.xcodeproj
|
||||
|
||||
|
|
|
@ -172,6 +172,8 @@ set(OC_CLONK_SOURCES
|
|||
src/control/C4Teams.h
|
||||
src/editor/C4Console.cpp
|
||||
src/editor/C4Console.h
|
||||
src/editor/C4ConsoleGUI.h
|
||||
src/editor/C4ConsoleGUICommon.cpp
|
||||
src/editor/C4DevmodeDlg.cpp
|
||||
src/editor/C4DevmodeDlg.h
|
||||
src/editor/C4EditCursor.cpp
|
||||
|
@ -478,6 +480,8 @@ set(OC_CLONK_SOURCES
|
|||
src/platform/StdVideo.cpp
|
||||
src/platform/StdVideo.h
|
||||
src/platform/StdWindow.h
|
||||
src/platform/StdAppCommon.h
|
||||
src/platform/StdAppCommon.cpp
|
||||
src/script/C4AList.cpp
|
||||
src/script/C4AList.h
|
||||
src/script/C4Aul.cpp
|
||||
|
@ -518,6 +522,7 @@ if(WIN32)
|
|||
src/platform/StdJoystick.cpp
|
||||
src/platform/StdJoystick.h
|
||||
src/platform/C4FileClasses.cpp
|
||||
src/editor/C4ConsoleWin32.cpp
|
||||
src/res/resource.h
|
||||
)
|
||||
|
||||
|
@ -583,6 +588,7 @@ if(USE_GTK)
|
|||
list(APPEND OC_SYSTEM_SOURCES
|
||||
src/platform/StdGtkWindow.cpp
|
||||
src/platform/StdGtkWindow.h
|
||||
src/editor/C4ConsoleGTK.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ void C4FullScreen::Execute()
|
|||
// Execute menu
|
||||
if (pMenu) pMenu->Execute();
|
||||
// Draw
|
||||
::GraphicsSystem.Execute();
|
||||
RequestUpdate();
|
||||
}
|
||||
|
||||
bool C4FullScreen::ViewportCheck()
|
||||
|
@ -522,6 +522,11 @@ void C4FullScreen::CloseMenu()
|
|||
}
|
||||
}
|
||||
|
||||
void C4FullScreen::PerformUpdate()
|
||||
{
|
||||
GraphicsSystem.Execute();
|
||||
}
|
||||
|
||||
bool C4FullScreen::MenuKeyControl(BYTE byCom)
|
||||
{
|
||||
if (pMenu) return pMenu->KeyControl(byCom);
|
||||
|
|
|
@ -50,9 +50,10 @@ public:
|
|||
virtual void CharIn(const char * c);
|
||||
#ifdef USE_X11
|
||||
virtual void HandleMessage (XEvent &e);
|
||||
#elif USE_SDL_MAINLOOP
|
||||
#elif defined(USE_SDL_MAINLOOP)
|
||||
virtual void HandleMessage (SDL_Event &e);
|
||||
#endif
|
||||
virtual void PerformUpdate();
|
||||
};
|
||||
|
||||
extern C4FullScreen FullScreen;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,6 +24,7 @@
|
|||
#ifndef INC_C4Console
|
||||
#define INC_C4Console
|
||||
|
||||
#include "C4ConsoleGUI.h"
|
||||
#include "C4PropertyDlg.h"
|
||||
#include "C4ToolsDlg.h"
|
||||
#include "C4ObjectListDlg.h"
|
||||
|
@ -31,10 +32,6 @@
|
|||
|
||||
#include <StdWindow.h>
|
||||
|
||||
#ifdef WITH_DEVELOPER_MODE
|
||||
# include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
const int C4CNS_ModePlay = 0,
|
||||
C4CNS_ModeEdit = 1,
|
||||
C4CNS_ModeDraw = 2;
|
||||
|
@ -53,16 +50,11 @@ typedef CStdGtkWindow C4ConsoleBase;
|
|||
typedef CStdWindow C4ConsoleBase;
|
||||
#endif
|
||||
|
||||
class C4Console: public C4ConsoleBase
|
||||
class C4Console: public C4ConsoleGUI
|
||||
{
|
||||
public:
|
||||
C4Console();
|
||||
virtual ~C4Console();
|
||||
bool Editing;
|
||||
C4PropertyDlg PropertyDlg;
|
||||
C4ToolsDlg ToolsDlg;
|
||||
C4ObjectListDlg ObjectListDlg;
|
||||
C4EditCursor EditCursor;
|
||||
void Default();
|
||||
virtual void Clear();
|
||||
virtual void Close();
|
||||
|
@ -71,28 +63,19 @@ public:
|
|||
void Execute();
|
||||
void ClearPointers(C4Object *pObj);
|
||||
bool Message(const char *szMessage, bool fQuery=false);
|
||||
void SetCaption(const char *szCaption);
|
||||
bool In(const char *szText);
|
||||
bool Out(const char *szText);
|
||||
bool ClearLog(); // empty log text
|
||||
void DoPlay();
|
||||
void DoHalt();
|
||||
bool UpdateCursorBar(const char *szCursor);
|
||||
bool UpdateHaltCtrls(bool fHalt);
|
||||
bool UpdateModeCtrls(int iMode);
|
||||
void UpdateInputCtrl();
|
||||
void UpdateMenus();
|
||||
bool OpenGame();
|
||||
bool TogglePause(); // key callpack: pause
|
||||
protected:
|
||||
public:
|
||||
bool CloseGame();
|
||||
bool fGameOpen;
|
||||
void EnableControls(bool fEnable);
|
||||
bool UpdatePlayerMenu();
|
||||
bool UpdateViewportMenu();
|
||||
bool UpdateStatusBars();
|
||||
// Menu
|
||||
void ClearPlayerMenu();
|
||||
void ClearViewportMenu();
|
||||
void UpdateNetMenu();
|
||||
void ClearNetMenu();
|
||||
|
@ -113,6 +96,12 @@ protected:
|
|||
bool FileClose();
|
||||
bool FileQuit();
|
||||
bool FileRecord();
|
||||
void SetCaptionToFilename(const char* szFilename);
|
||||
public:
|
||||
C4PropertyDlg PropertyDlg;
|
||||
C4ToolsDlg ToolsDlg;
|
||||
C4ObjectListDlg ObjectListDlg;
|
||||
C4EditCursor EditCursor;
|
||||
|
||||
int ScriptCounter;
|
||||
int FrameCounter;
|
||||
|
@ -123,107 +112,7 @@ protected:
|
|||
int MenuIndexViewport;
|
||||
int MenuIndexNet;
|
||||
int MenuIndexHelp;
|
||||
#ifdef _WIN32
|
||||
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)
|
||||
#if defined(USE_X11) && !defined(WITH_DEVELOPER_MODE)
|
||||
virtual void HandleMessage (XEvent &);
|
||||
#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>
|
||||
|
||||
#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()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
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
|
||||
Console.PropertyDlgOpen(this);
|
||||
Active = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -239,135 +121,41 @@ bool C4PropertyDlg::Update()
|
|||
break;
|
||||
}
|
||||
// Update info edit control
|
||||
#ifdef _WIN32
|
||||
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
|
||||
Console.PropertyDlgUpdate(this, Output);
|
||||
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)
|
||||
{
|
||||
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
|
||||
std::vector<char*> functions;
|
||||
for (C4AulFunc *pFn = ::ScriptEngine.GetFirstFunc(); pFn; pFn = ::ScriptEngine.GetNextFunc(pFn))
|
||||
{
|
||||
if (pFn->GetPublic())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
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
|
||||
functions.push_back(pFn->Name);
|
||||
}
|
||||
}
|
||||
// Add object script functions
|
||||
#ifdef _WIN32
|
||||
bool fDivider = false;
|
||||
#endif
|
||||
C4AulScriptFunc *pRef;
|
||||
// Object script available
|
||||
if (pObj && pObj->Def)
|
||||
{
|
||||
// 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
|
||||
if ((pRef->Access=AA_PUBLIC))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Insert divider if necessary
|
||||
if (!fDivider) { SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)"----------"); fDivider=true; }
|
||||
#endif
|
||||
if (!fDivider) { functions.push_back((char*)C4ConsoleGUI::LIST_DIVIDER); fDivider=true; }
|
||||
// Add function
|
||||
#ifdef _WIN32
|
||||
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
|
||||
functions.push_back(pRef->Name);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Restore old text
|
||||
SetWindowText(hCombo,szLastText);
|
||||
#elif defined(WITH_DEVELOPER_MODE)
|
||||
// Reassociate list store with completion
|
||||
gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Console.PropertyDlgSetFunctions(this, functions);
|
||||
}
|
||||
|
||||
void C4PropertyDlg::Execute()
|
||||
|
@ -379,24 +167,3 @@ void C4PropertyDlg::ClearPointers(C4Object *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"
|
||||
|
||||
#ifdef WITH_DEVELOPER_MODE
|
||||
# include <gtk/gtk.h>
|
||||
#endif
|
||||
#include "C4ConsoleGUI.h"
|
||||
|
||||
class C4PropertyDlg
|
||||
{
|
||||
friend class C4ConsoleGUI;
|
||||
private:
|
||||
class State;
|
||||
State *state;
|
||||
public:
|
||||
C4PropertyDlg();
|
||||
~C4PropertyDlg();
|
||||
|
@ -44,24 +46,7 @@ public:
|
|||
bool Update();
|
||||
bool Update(C4ObjectList &rSelection);
|
||||
bool Active;
|
||||
#ifdef _WIN32
|
||||
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:
|
||||
public: // ToolsDlg fields are public as well...
|
||||
C4ID idSelectedDef;
|
||||
C4ObjectList Selection;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,14 +29,17 @@
|
|||
#endif
|
||||
|
||||
#include "C4Constants.h"
|
||||
#include "C4ConsoleGUI.h"
|
||||
|
||||
const int32_t C4TLS_Brush = 0,
|
||||
const int32_t
|
||||
C4TLS_Brush = 0,
|
||||
C4TLS_Line = 1,
|
||||
C4TLS_Rect = 2,
|
||||
C4TLS_Fill = 3,
|
||||
C4TLS_Picker = 4;
|
||||
|
||||
const int32_t C4TLS_GradeMax = 50,
|
||||
const int32_t
|
||||
C4TLS_GradeMax = 50,
|
||||
C4TLS_GradeMin = 1,
|
||||
C4TLS_GradeDefault = 5;
|
||||
|
||||
|
@ -44,103 +47,27 @@ const int32_t C4TLS_GradeMax = 50,
|
|||
|
||||
class C4ToolsDlg
|
||||
{
|
||||
#ifdef _WIN32
|
||||
friend INT_PTR CALLBACK ToolsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
friend class C4ConsoleGUI;
|
||||
private:
|
||||
class State;
|
||||
State *state;
|
||||
public:
|
||||
C4ToolsDlg();
|
||||
~C4ToolsDlg();
|
||||
public:
|
||||
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 Grade;
|
||||
bool ModeIFT;
|
||||
char Material[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:
|
||||
void Default();
|
||||
void Clear();
|
||||
bool PopTextures();
|
||||
bool PopMaterial();
|
||||
bool ChangeGrade(int32_t iChange);
|
||||
void UpdatePreview();
|
||||
void NeedPreviewUpdate();
|
||||
bool Open();
|
||||
bool SetGrade(int32_t iGrade);
|
||||
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 IsExternalDrawDialog() { 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
|
||||
virtual bool CheckNameHotkey(const char * c) { return false; }
|
||||
|
@ -1937,16 +1938,21 @@ namespace C4GUI
|
|||
friend class ComboBox_FillCB;
|
||||
};
|
||||
|
||||
class Dialog;
|
||||
|
||||
// EM window class
|
||||
class DialogWindow : public CStdWindow
|
||||
{
|
||||
public:
|
||||
Dialog* pDialog;
|
||||
DialogWindow(): CStdWindow(), pDialog(NULL) {}
|
||||
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();
|
||||
#if defined(USE_X11)
|
||||
#ifdef USE_X11
|
||||
virtual void HandleMessage (XEvent &);
|
||||
#endif
|
||||
virtual void PerformUpdate();
|
||||
};
|
||||
|
||||
// information on how to draw dialog borders and face
|
||||
|
@ -1978,7 +1984,7 @@ namespace C4GUI
|
|||
};
|
||||
|
||||
// a dialog
|
||||
class Dialog : public Window
|
||||
class Dialog: public Window
|
||||
{
|
||||
private:
|
||||
enum Fade { eFadeNone=0, eFadeOut, eFadeIn };
|
||||
|
@ -2024,6 +2030,7 @@ namespace C4GUI
|
|||
void SetFocus(Control *pCtrl, bool fByMouse);
|
||||
Control *GetFocus() { return pActiveCtrl; }
|
||||
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 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
|
||||
#include "resource.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_X11
|
||||
#define None Die_XLib_Die
|
||||
#include <X11/Xlib.h>
|
||||
|
@ -190,7 +191,7 @@ namespace C4GUI
|
|||
// DialogWindow
|
||||
|
||||
#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;
|
||||
// calculate required size
|
||||
|
@ -311,18 +312,21 @@ namespace C4GUI
|
|||
return !!RegisterClassEx(&WndClass);
|
||||
}
|
||||
#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
|
||||
if (szID && *szID)
|
||||
RestorePosition(FormatString("ConsoleGUI_%s", szID).getData(), Config.GetSubkeyPath("Console"), false);
|
||||
else
|
||||
SetSize(rcBounds.Wdt, rcBounds.Hgt);
|
||||
return this;
|
||||
result = this;
|
||||
}
|
||||
return NULL;
|
||||
else
|
||||
result = NULL;
|
||||
return result;
|
||||
}
|
||||
#ifdef USE_X11
|
||||
void DialogWindow::HandleMessage (XEvent &e)
|
||||
|
@ -427,6 +431,26 @@ namespace C4GUI
|
|||
#endif
|
||||
#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()
|
||||
{
|
||||
// FIXME: Close the dialog of this window
|
||||
|
@ -440,7 +464,7 @@ namespace C4GUI
|
|||
if (pWindow) return true;
|
||||
// create it!
|
||||
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;
|
||||
pWindow = NULL;
|
||||
|
@ -448,6 +472,7 @@ namespace C4GUI
|
|||
}
|
||||
// create rendering context
|
||||
pWindow->pSurface = new CSurface(&Application, pWindow);
|
||||
pWindow->pDialog = this;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <shellapi.h>
|
||||
|
||||
bool C4Viewport::DropFiles(HANDLE hDrop)
|
||||
{
|
||||
if (!Console.Editing) { Console.Message(LoadResStr("IDS_CNS_NONETEDIT")); return false; }
|
||||
|
@ -771,7 +772,10 @@ void C4ViewportList::Execute(bool DrawBackground)
|
|||
if (DrawBackground)
|
||||
DrawFullscreenBackground();
|
||||
for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
|
||||
cvp->Execute();
|
||||
{
|
||||
if (cvp->GetWindow())
|
||||
cvp->GetWindow()->RequestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void C4ViewportList::DrawFullscreenBackground()
|
||||
|
|
|
@ -94,6 +94,8 @@ protected:
|
|||
void DrawPlayerInfo(C4TargetFacet &cgo);
|
||||
void BlitOutput();
|
||||
void AdjustPosition();
|
||||
public:
|
||||
C4ViewportWindow* GetWindow() {return pWindow;}
|
||||
bool UpdateOutputSize();
|
||||
bool ViewPositionByScrollBars();
|
||||
bool ScrollBarsByViewPosition();
|
||||
|
|
|
@ -116,7 +116,7 @@ bool C4SoundEffect::Load(BYTE *pData, size_t iDataLen, bool fStatic, bool fRaw)
|
|||
// Set usage time
|
||||
UsageTime=Game.Time;
|
||||
Static=fStatic;
|
||||
return pSample;
|
||||
return !!pSample;
|
||||
}
|
||||
|
||||
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.
|
||||
if (LOWORD(wParam) == WA_INACTIVE)
|
||||
{
|
||||
if (Console.PropertyDlg.hDialog)
|
||||
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));
|
||||
Console.Win32KeepDialogsFloating();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -159,10 +156,7 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
case WM_MOUSEACTIVATE:
|
||||
// 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.
|
||||
if (Console.PropertyDlg.hDialog)
|
||||
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));
|
||||
Console.Win32KeepDialogsFloating(hwnd);
|
||||
}
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -250,7 +244,7 @@ bool C4ViewportWindow::RegisterViewportClass(HINSTANCE 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;
|
||||
// Create window
|
||||
|
@ -665,10 +659,12 @@ void C4ViewportWindow::OnHScrollStatic(GtkAdjustment* adjustment, gpointer user_
|
|||
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::ScrollBarsByViewPosition() { return false; }
|
||||
#if defined(USE_X11)
|
||||
|
||||
void C4ViewportWindow::HandleMessage (XEvent & e)
|
||||
{
|
||||
switch (e.type)
|
||||
|
@ -800,7 +796,15 @@ void C4ViewportWindow::HandleMessage (XEvent & e)
|
|||
}
|
||||
}
|
||||
#endif // USE_X11
|
||||
#endif // WITH_DEVELOPER_MODE/_WIN32
|
||||
|
||||
void C4ViewportWindow::PerformUpdate()
|
||||
{
|
||||
if (cvp)
|
||||
{
|
||||
cvp->UpdateOutputSize();
|
||||
cvp->Execute();
|
||||
}
|
||||
}
|
||||
|
||||
void C4ViewportWindow::Close()
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
C4Viewport * cvp;
|
||||
C4ViewportWindow(C4Viewport * cvp): cvp(cvp) { }
|
||||
#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);
|
||||
#elif defined(WITH_DEVELOPER_MODE)
|
||||
virtual GtkWidget* InitGUI();
|
||||
|
@ -70,6 +70,7 @@ public:
|
|||
#endif
|
||||
void EditCursorMove(int X, int Y, uint16_t);
|
||||
virtual void Close();
|
||||
virtual void PerformUpdate();
|
||||
};
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
void CStdWindow::RequestUpdate()
|
||||
{
|
||||
// just invoke directly
|
||||
PerformUpdate();
|
||||
}
|
||||
|
|
|
@ -483,3 +483,9 @@ bool CStdApp::IsClipboardFull(bool fClipboard)
|
|||
void CStdApp::ClearClipboard(bool fClipboard)
|
||||
{
|
||||
}
|
||||
|
||||
void CStdWindow::RequestUpdate()
|
||||
{
|
||||
// just invoke directly
|
||||
PerformUpdate();
|
||||
}
|
|
@ -240,6 +240,13 @@ typedef struct _XDisplay Display;
|
|||
|
||||
class CStdWindow
|
||||
{
|
||||
public:
|
||||
enum WindowKind
|
||||
{
|
||||
W_GuiWindow,
|
||||
W_Viewport,
|
||||
W_Fullscreen
|
||||
};
|
||||
public:
|
||||
CStdWindow ();
|
||||
virtual ~CStdWindow ();
|
||||
|
@ -253,7 +260,7 @@ public:
|
|||
virtual void CharIn(const char * c) { }
|
||||
virtual CStdWindow * Init(CStdApp * pApp);
|
||||
#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
|
||||
bool StorePosition(const char *szWindowName, const char *szSubKey, bool fStoreSize = true);
|
||||
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 SetTitle(const char * Title);
|
||||
void FlashWindow();
|
||||
protected:
|
||||
|
||||
#ifdef _WIN32
|
||||
public:
|
||||
HWND hWindow;
|
||||
|
@ -287,6 +294,12 @@ private:
|
|||
protected:
|
||||
virtual void HandleMessage(SDL_Event&) {}
|
||||
#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 CStdGL;
|
||||
friend class CStdGLCtx;
|
||||
|
@ -375,28 +388,13 @@ public:
|
|||
virtual void Clear();
|
||||
|
||||
bool Init(int argc, char * argv[]);
|
||||
void Run()
|
||||
{
|
||||
// Main message loop
|
||||
while (!fQuitMsgReceived)
|
||||
ScheduleProcs();
|
||||
}
|
||||
void Run();
|
||||
virtual void Quit();
|
||||
|
||||
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);
|
||||
void RestoreVideoMode();
|
||||
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 ScheduleProcs(int iTimeout = -1);
|
||||
bool FlushMessages();
|
||||
CStdWindow * pWindow;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
dpy = pApp->dpy;
|
||||
|
|
Loading…
Reference in New Issue