OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Console Class Reference

#include <C4Console.h>

Inheritance diagram for C4Console:
[legend]
Collaboration diagram for C4Console:
[legend]

Public Types

enum  RecentScriptInputLists { MRU_Scenario = 0, MRU_Object = 1 }
 
enum  InfoTextType { CONSOLE_Cursor, CONSOLE_FrameCounter, CONSOLE_TimeFPS }
 
enum  Stage { STAGE_Start, STAGE_Intermediate, STAGE_End }
 
enum  Cursor { CURSOR_Normal, CURSOR_Wait }
 
enum  ClientOperation { CO_None, CO_Deactivate, CO_Activate, CO_Kick }
 
enum  WindowKind {
  W_GuiWindow, W_Console, W_Viewport, W_Fullscreen,
  W_Control
}
 

Public Member Functions

 C4Console ()
 
 ~C4Console () override
 
void Default ()
 
void Clear () override
 
void Close () override
 
virtual C4WindowInit (C4AbstractApp *app)
 
void Execute ()
 
void ClearPointers (C4Object *pObj)
 
bool Message (const char *szMessage, bool fQuery=false)
 
bool In (const char *szText)
 
void DoPlay ()
 
void DoHalt ()
 
void UpdateInputCtrl ()
 
void UpdateMenus ()
 
void InitGame ()
 
bool TogglePause ()
 
void CloseGame ()
 
bool UpdatePlayerMenu ()
 
bool UpdateViewportMenu ()
 
void UpdateStatusBars ()
 
void ClearViewportMenu ()
 
void UpdateNetMenu ()
 
void ClearNetMenu ()
 
void PlayerJoin ()
 
void ViewportNew ()
 
void HelpAbout ()
 
bool FileSelect (StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
 
bool SaveGame (const char *path)
 
bool SaveScenario (const char *path, bool export_packed=false)
 
bool FileSaveAs (bool fSaveGame, bool export_packed=false)
 
bool FileSave ()
 
bool FileNew ()
 
bool FileOpen (const char *filename=nullptr, bool host_in_network=false)
 
bool FileOpenWPlrs ()
 
bool FileCommand ()
 
bool FileClose ()
 
bool FileQuit ()
 
bool FileRecord ()
 
void SetCaptionToFilename (const char *szFilename)
 
std::list< const char * > GetScriptSuggestions (class C4PropList *target, RecentScriptInputLists section) const
 
void RegisterRecentInput (const char *input, RecentScriptInputLists section)
 
void AddViewport (C4ViewportWindow *cvp)
 
void RemoveViewport (C4ViewportWindow *cvp)
 
void OnObjectSelectionChanged (class C4EditCursorSelection &selection)
 
bool CreateNewScenario (StdStrBuf *out_filename, bool *out_host_as_network)
 
void OnStartGame ()
 
void EnsureDefinitionListInitialized ()
 
void CloseConsoleWindow ()
 
void EditGraphControl (const class C4ControlEditGraph *control)
 
void SetCursor (Cursor cursor)
 
void RecordingEnabled ()
 
void ShowAboutWithCopyright (StdStrBuf &copyright)
 
bool UpdateModeCtrls (int iMode)
 
void AddNetMenu ()
 
void AddNetMenuItemForPlayer (int32_t client_id, const char *text, C4ConsoleGUI::ClientOperation co)
 
void ClearPlayerMenu ()
 
void SetInputFunctions (std::list< const char * > &functions)
 
bool CreateConsoleWindow (C4AbstractApp *application)
 
void DeleteConsoleWindow ()
 
void Out (const char *message)
 
bool ClearLog ()
 
void DisplayInfoText (InfoTextType type, StdStrBuf &text)
 
void SetCaptionToFileName (const char *file_name)
 
void AddMenuItemForPlayer (C4Player *player, StdStrBuf &player_text)
 
void AddKickPlayerMenuItem (C4Player *player, StdStrBuf &player_text, bool enabled)
 
void EnableControls (bool fEnable)
 
void DoEnableControls (bool fEnable)
 
bool UpdateHaltCtrls (bool fHalt)
 
bool DoUpdateHaltCtrls (bool fHalt)
 
bool PropertyDlgOpen ()
 
void PropertyDlgClose ()
 
void PropertyDlgUpdate (class C4EditCursorSelection &rSelection, bool force_function_update)
 
bool ToolsDlgOpen (class C4ToolsDlg *dlg)
 
void ToolsDlgClose ()
 
void ToolsDlgInitMaterialCtrls (class C4ToolsDlg *dlg)
 
void ToolsDlgSelectTexture (C4ToolsDlg *dlg, const char *texture)
 
void ToolsDlgSelectMaterial (C4ToolsDlg *dlg, const char *material)
 
void ToolsDlgSelectBackTexture (C4ToolsDlg *dlg, const char *texture)
 
void ToolsDlgSelectBackMaterial (C4ToolsDlg *dlg, const char *material)
 
virtual void CharIn (const char *)
 
virtual bool ReInit (C4AbstractApp *pApp)
 
virtual void EnumerateMultiSamples (std::vector< int > &samples) const
 
bool StorePosition (const char *szWindowName, const char *szSubKey, bool fStoreSize=true)
 
bool RestorePosition (const char *szWindowName, const char *szSubKey, bool fHidden=false)
 
bool GetSize (C4Rect *pRect)
 
void SetSize (unsigned int cx, unsigned int cy)
 
void SetTitle (const char *Title)
 
void FlashWindow ()
 
void GrabMouse (bool grab)
 
virtual void RequestUpdate ()
 
virtual void PerformUpdate ()
 

Public Attributes

C4ToolsDlg ToolsDlg
 
C4ObjectListDlg ObjectListDlg
 
C4EditCursor EditCursor
 
int FrameCounter
 
int Time
 
int FPS
 
bool Editing
 
bool fGameOpen
 
C4ObjectPropertyDlgObject
 
bool Active {false}
 
C4SurfacepSurface {nullptr}
 
WindowKind eKind
 

Protected Member Functions

virtual C4WindowInit (WindowKind windowKind, C4AbstractApp *pApp, const char *Title, const C4Rect *size)
 

Detailed Description

Definition at line 42 of file C4Console.h.

Member Enumeration Documentation

Enumerator
CO_None 
CO_Deactivate 
CO_Activate 
CO_Kick 

Definition at line 70 of file C4ConsoleGUI.h.

enum C4ConsoleGUI::Cursor
inherited
Enumerator
CURSOR_Normal 
CURSOR_Wait 

Definition at line 64 of file C4ConsoleGUI.h.

Enumerator
CONSOLE_Cursor 
CONSOLE_FrameCounter 
CONSOLE_TimeFPS 

Definition at line 50 of file C4ConsoleGUI.h.

Enumerator
MRU_Scenario 
MRU_Object 

Definition at line 96 of file C4Console.h.

97  {
98  MRU_Scenario = 0,
99  MRU_Object = 1
100  };
enum C4ConsoleGUI::Stage
inherited
Enumerator
STAGE_Start 
STAGE_Intermediate 
STAGE_End 

Definition at line 57 of file C4ConsoleGUI.h.

enum C4Window::WindowKind
inherited
Enumerator
W_GuiWindow 
W_Console 
W_Viewport 
W_Fullscreen 
W_Control 

Definition at line 262 of file C4Window.h.

263  {
264  W_GuiWindow,
265  W_Console,
266  W_Viewport,
267  W_Fullscreen,
268  W_Control // wrapper to a render target control inside a window
269  };

Constructor & Destructor Documentation

C4Console::C4Console ( )

Definition at line 44 of file C4Console.cpp.

References C4Window::Active, C4ConsoleGUI::Editing, C4ConsoleGUI::fGameOpen, and FrameCounter.

44  : C4ConsoleGUI()
45 {
46  Active = false;
47  Editing = true;
48  FrameCounter=0;
49  fGameOpen=false;
50 
51 #ifdef USE_WIN32_WINDOWS
52  hWindow=nullptr;
53 #endif
54 }
int FrameCounter
Definition: C4Console.h:92
bool Active
Definition: C4Window.h:273
C4Console::~C4Console ( )
overridedefault

Member Function Documentation

void C4ConsoleGUI::AddKickPlayerMenuItem ( C4Player player,
StdStrBuf player_text,
bool  enabled 
)
inherited

Definition at line 662 of file C4Console.cpp.

Referenced by UpdatePlayerMenu().

662 {}

Here is the caller graph for this function:

void C4ConsoleGUI::AddMenuItemForPlayer ( C4Player player,
StdStrBuf player_text 
)
inherited

Definition at line 663 of file C4Console.cpp.

Referenced by UpdateViewportMenu().

663 {}

Here is the caller graph for this function:

void C4ConsoleGUI::AddNetMenu ( )
inherited

Definition at line 665 of file C4Console.cpp.

Referenced by UpdateNetMenu().

665 {}

Here is the caller graph for this function:

void C4ConsoleGUI::AddNetMenuItemForPlayer ( int32_t  client_id,
const char *  text,
C4ConsoleGUI::ClientOperation  co 
)
inherited

Definition at line 664 of file C4Console.cpp.

Referenced by UpdateNetMenu().

664 {}

Here is the caller graph for this function:

void C4ConsoleGUI::AddViewport ( C4ViewportWindow cvp)
inlineinherited

Definition at line 110 of file C4ConsoleGUI.h.

110 { }
virtual void C4Window::CharIn ( const char *  )
inlinevirtualinherited

Reimplemented in C4FullScreen.

Definition at line 281 of file C4Window.h.

281 { }
void C4Console::Clear ( )
overridevirtual

Reimplemented from C4Window.

Definition at line 418 of file C4Console.cpp.

References Application, C4ToolsDlg::Clear(), C4EditCursor::Clear(), C4Window::Clear(), ClearNetMenu(), C4ConsoleGUI::ClearPlayerMenu(), ClearViewportMenu(), C4ConsoleGUI::DeleteConsoleWindow(), EditCursor, C4ConsoleGUI::PropertyDlgClose(), C4Window::pSurface, C4Application::Quit(), and ToolsDlg.

Referenced by C4Application::Clear().

419 {
420  if (pSurface) delete pSurface;
421  pSurface = nullptr;
422 
423  C4Window::Clear();
425 
426  EditCursor.Clear();
427  ToolsDlg.Clear();
430  ClearPlayerMenu();
431  ClearNetMenu();
432 #ifndef _WIN32
433  Application.Quit();
434 #endif
435 }
C4EditCursor EditCursor
Definition: C4Console.h:90
void ClearNetMenu()
Definition: C4Console.cpp:569
void ClearViewportMenu()
Definition: C4Console.cpp:475
void DeleteConsoleWindow()
Definition: C4Console.cpp:678
C4ToolsDlg ToolsDlg
Definition: C4Console.h:88
C4Surface * pSurface
Definition: C4Window.h:274
void Quit() override
virtual void Clear()
Definition: C4AppT.cpp:99
void ClearPlayerMenu()
Definition: C4Console.cpp:669
C4Application Application
Definition: C4Globals.cpp:44
void PropertyDlgClose()
Definition: C4Console.cpp:686

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ConsoleGUI::ClearLog ( )
inherited

Definition at line 667 of file C4Console.cpp.

Referenced by C4MessageInput::ProcessCommand().

667 {return false;}

Here is the caller graph for this function:

void C4Console::ClearNetMenu ( )

Definition at line 569 of file C4Console.cpp.

References C4Window::Active, and C4ConsoleGUI::ClearNetMenu().

Referenced by Clear(), and UpdateNetMenu().

570 {
571  if (!Active) return;
573 }
void ClearNetMenu()
Definition: C4Console.cpp:668
bool Active
Definition: C4Window.h:273

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::ClearPlayerMenu ( )
inherited

Definition at line 669 of file C4Console.cpp.

Referenced by Clear(), and UpdatePlayerMenu().

669 {}

Here is the caller graph for this function:

void C4Console::ClearPointers ( C4Object pObj)

Definition at line 405 of file C4Console.cpp.

References C4EditCursor::ClearPointers(), C4ConsoleGUI::ClearPointers(), and EditCursor.

Referenced by C4Game::ClearPointers().

406 {
409 }
C4EditCursor EditCursor
Definition: C4Console.h:90
void ClearPointers(C4Object *pObj)
void ClearPointers(class C4Object *obj)
Definition: C4ConsoleGUI.h:117

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::ClearViewportMenu ( )

Definition at line 475 of file C4Console.cpp.

References C4Window::Active, and C4ConsoleGUI::ClearViewportMenu().

Referenced by Clear(), and UpdateViewportMenu().

476 {
477  if (!Active) return;
479 }
void ClearViewportMenu()
Definition: C4Console.cpp:670
bool Active
Definition: C4Window.h:273

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::Close ( )
overridevirtual

Implements C4Window.

Definition at line 437 of file C4Console.cpp.

References Application, C4ConsoleGUI::CloseConsoleWindow(), and C4Application::Quit().

Referenced by ConsoleDlgProc(), and FileQuit().

438 {
440  Application.Quit();
441 }
void CloseConsoleWindow()
Definition: C4ConsoleGUI.h:116
void Quit() override
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::CloseConsoleWindow ( )
inlineinherited

Definition at line 116 of file C4ConsoleGUI.h.

Referenced by Close().

116 {}

Here is the caller graph for this function:

void C4Console::CloseGame ( )

Definition at line 609 of file C4Console.cpp.

References C4Window::Active, C4ConsoleGUI::EnableControls(), C4ConsoleGUI::fGameOpen, LoadResStr(), and C4Window::SetTitle().

Referenced by C4Game::Clear().

610 {
611  if (!Active || !fGameOpen) return;
612  fGameOpen=false;
614  SetTitle(LoadResStr("IDS_CNS_CONSOLE"));
615 }
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:143
void SetTitle(const char *Title)
Definition: C4AppT.cpp:111
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Active
Definition: C4Window.h:273

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ConsoleGUI::CreateConsoleWindow ( C4AbstractApp application)
inherited

Definition at line 671 of file C4Console.cpp.

References C4Window::Init(), LoadResStr(), and C4Window::W_Console.

Referenced by Init().

672 {
673  C4Rect r(0, 0, 400, 350);
674  if (!C4Window::Init(C4Window::W_Console, pApp, LoadResStr("IDS_CNS_CONSOLE"), &r))
675  return false;
676  return true;
677 }
Definition: C4Rect.h:27
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
virtual C4Window * Init(WindowKind windowKind, C4AbstractApp *pApp, const char *Title, const C4Rect *size)
Definition: C4AppT.cpp:106

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ConsoleGUI::CreateNewScenario ( StdStrBuf out_filename,
bool *  out_host_as_network 
)
inlineinherited

Definition at line 113 of file C4ConsoleGUI.h.

Referenced by FileNew().

113 { return false; }

Here is the caller graph for this function:

void C4Console::Default ( )

Definition at line 411 of file C4Console.cpp.

References C4ToolsDlg::Default(), C4EditCursor::Default(), EditCursor, C4ConsoleGUI::PropertyDlgObject, and ToolsDlg.

Referenced by InitGame().

412 {
414  PropertyDlgObject = nullptr;
415  ToolsDlg.Default();
416 }
C4EditCursor EditCursor
Definition: C4Console.h:90
C4ToolsDlg ToolsDlg
Definition: C4Console.h:88
C4Object * PropertyDlgObject
Definition: C4ConsoleGUI.h:164

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::DeleteConsoleWindow ( )
inherited

Definition at line 678 of file C4Console.cpp.

Referenced by Clear().

678 {}

Here is the caller graph for this function:

void C4ConsoleGUI::DisplayInfoText ( C4ConsoleGUI::InfoTextType  type,
StdStrBuf text 
)
inherited

Definition at line 679 of file C4Console.cpp.

Referenced by C4EditCursor::UpdateStatusBar(), and UpdateStatusBars().

679 {}

Here is the caller graph for this function:

void C4ConsoleGUI::DoEnableControls ( bool  fEnable)
inherited

Definition at line 680 of file C4Console.cpp.

Referenced by C4ConsoleGUI::EnableControls().

680 {}

Here is the caller graph for this function:

void C4Console::DoHalt ( )

Definition at line 100 of file C4Console.cpp.

References Game, and C4Game::Pause().

Referenced by ConsoleDlgProc().

101 {
102  Game.Pause();
103 }
C4Game Game
Definition: C4Globals.cpp:52
bool Pause()
Definition: C4Game.cpp:950

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::DoPlay ( )

Definition at line 95 of file C4Console.cpp.

References Game, and C4Game::Unpause().

Referenced by ConsoleDlgProc().

96 {
97  Game.Unpause();
98 }
C4Game Game
Definition: C4Globals.cpp:52
bool Unpause()
Definition: C4Game.cpp:976

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ConsoleGUI::DoUpdateHaltCtrls ( bool  fHalt)
inherited

Definition at line 681 of file C4Console.cpp.

Referenced by C4ConsoleGUI::UpdateHaltCtrls().

681 {return false;}

Here is the caller graph for this function:

void C4ConsoleGUI::EditGraphControl ( const class C4ControlEditGraph control)
inlineinherited

Definition at line 118 of file C4ConsoleGUI.h.

118 {}
void C4ConsoleGUI::EnableControls ( bool  fEnable)
inlineinherited

Definition at line 143 of file C4ConsoleGUI.h.

References C4Window::Active, Control, C4ConsoleGUI::DoEnableControls(), and C4GameControl::NoInput().

Referenced by CloseGame(), InitGame(), and UpdateMenus().

144  {
145  if (!Active) return;
146  // disable Editing if no input allowed
147  Editing &= !::Control.NoInput();
148  DoEnableControls(fEnable);
149  }
C4GameControl Control
bool NoInput() const
bool Active
Definition: C4Window.h:273
void DoEnableControls(bool fEnable)
Definition: C4Console.cpp:680

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::EnsureDefinitionListInitialized ( )
inlineinherited

Definition at line 115 of file C4ConsoleGUI.h.

115 { }
void C4Window::EnumerateMultiSamples ( std::vector< int > &  samples) const
virtualinherited

Definition at line 102 of file C4AppT.cpp.

Referenced by C4StartupOptionsDlg::C4StartupOptionsDlg().

102 {}

Here is the caller graph for this function:

void C4Console::Execute ( )

Definition at line 581 of file C4Console.cpp.

References EditCursor, C4ObjectListDlg::Execute(), C4GraphicsSystem::Execute(), C4EditCursor::Execute(), C4ConsoleGUI::Execute(), GraphicsSystem, ObjectListDlg, and UpdateStatusBars().

Referenced by C4Application::Draw().

582 {
588 }
C4EditCursor EditCursor
Definition: C4Console.h:90
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
void Execute()
Definition: C4ConsoleGUI.h:109
C4ObjectListDlg ObjectListDlg
Definition: C4Console.h:89
void UpdateStatusBars()
Definition: C4Console.cpp:105

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileClose ( )

Definition at line 382 of file C4Console.cpp.

References Application, C4ConsoleGUI::fGameOpen, and C4Application::QuitGame().

Referenced by C4AppDelegate::closeScenario:, ConsoleDlgProc(), and C4AppDelegate::suggestQuitting:.

383 {
384  if (!fGameOpen) return false;
386  return true;
387 }
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileCommand ( )
bool C4Console::FileNew ( )

Definition at line 298 of file C4Console.cpp.

References C4ConfigDeveloper::AddRecentlyEditedScenario(), Application, C4Application::ClearCommandLine(), Config, C4ConsoleGUI::CreateNewScenario(), C4Config::Developer, C4Game::fLobby, Game, StdStrBuf::getData(), C4Game::NetworkActive, and C4Application::OpenGame().

299 {
300  StdCopyStrBuf filename;
301 #ifdef WITH_QT_EDITOR
302  bool host_in_network = false;
303  if (!C4ConsoleGUI::CreateNewScenario(&filename, &host_in_network)) return false;
306  if (host_in_network)
307  {
308  Game.NetworkActive = true;
309  Game.fLobby = true;
310  }
311  Application.OpenGame(filename.getData());
312  return true;
313 #endif
314  // Not implemented
315  return false;
316 
317 }
const char * getData() const
Definition: StdBuf.h:442
void OpenGame(const char *scenario=nullptr)
C4Config Config
Definition: C4Config.cpp:833
C4Game Game
Definition: C4Globals.cpp:52
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:96
bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network)
Definition: C4ConsoleGUI.h:113
C4ConfigDeveloper Developer
Definition: C4Config.h:252
bool NetworkActive
Definition: C4Game.h:122
void ClearCommandLine()
bool fLobby
Definition: C4Game.h:118
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

bool C4Console::FileOpen ( const char *  filename = nullptr,
bool  host_in_network = false 
)

Definition at line 319 of file C4Console.cpp.

References C4ConfigDeveloper::AddRecentlyEditedScenario(), Application, C4Application::ClearCommandLine(), Config, C4Config::Developer, FILE_SELECT_FILTER_FOR_C4S, FileSelect(), C4Game::fLobby, Game, StdStrBuf::getData(), C4Game::NetworkActive, OpenFileFlags::OFN_FILEMUSTEXIST, OpenFileFlags::OFN_HIDEREADONLY, and C4Application::OpenGame().

Referenced by ConsoleDlgProc(), and C4AppDelegate::openScenario:.

320 {
321  // Get scenario file name
322  StdCopyStrBuf c4sfile("");
323  if (!filename)
324  {
325  if (!FileSelect(&c4sfile,
328  return false;
329  filename = c4sfile.getData();
330  }
333  if (host_in_network)
334  {
335  Game.NetworkActive = true;
336  Game.fLobby = true;
337  }
338  // Open game
339  Application.OpenGame(filename);
340  return true;
341 }
void OpenGame(const char *scenario=nullptr)
C4Config Config
Definition: C4Config.cpp:833
C4Game Game
Definition: C4Globals.cpp:52
#define FILE_SELECT_FILTER_FOR_C4S
Definition: C4Console.cpp:38
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:96
const DWORD OFN_FILEMUSTEXIST
Definition: C4ConsoleGUI.h:28
C4ConfigDeveloper Developer
Definition: C4Config.h:252
bool NetworkActive
Definition: C4Game.h:122
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:26
void ClearCommandLine()
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:389
bool fLobby
Definition: C4Game.h:118
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileOpenWPlrs ( )

Definition at line 343 of file C4Console.cpp.

References C4ConfigDeveloper::AddRecentlyEditedScenario(), Application, C4Application::ClearCommandLine(), Config, C4Config::Developer, DirectoryExists(), DirSep, FILE_SELECT_FILTER_FOR_C4S, FileSelect(), Game, StdStrBuf::getData(), OpenFileFlags::OFN_ALLOWMULTISELECT, OpenFileFlags::OFN_EXPLORER, OpenFileFlags::OFN_FILEMUSTEXIST, OpenFileFlags::OFN_HIDEREADONLY, C4Application::OpenGame(), C4Game::PlayerFilenames, SAddModule(), SAppend(), and SLen().

Referenced by ConsoleDlgProc(), and C4AppDelegate::openScenarioWithPlayers:.

344 {
345  // Get scenario file name
346  StdCopyStrBuf c4sfile("");
347  if (!FileSelect(&c4sfile,
350  return false;
351  // Get player file name(s)
352  StdCopyStrBuf c4pfile("");
353  if (!FileSelect(&c4pfile,
354  "OpenClonk Player\0*.ocp\0\0",
356  )) return false;
357  // Compose command line
359  if (DirectoryExists(c4pfile.getData())) // Multiplayer
360  {
361  const char *cptr = c4pfile.getData() + SLen(c4pfile.getData()) + 1;
362  while (*cptr)
363  {
364  char c4pfile2[512 + 1] = "";
365  SAppend(c4pfile.getData(), c4pfile2, 512);
366  SAppend(DirSep, c4pfile2, 512);
367  SAppend(cptr, c4pfile2, 512);
368  SAddModule(Game.PlayerFilenames, c4pfile2);
369  cptr += SLen(cptr) + 1;
370  }
371  }
372  else // Single player
373  {
374  SAddModule(Game.PlayerFilenames, c4pfile.getData());
375  }
376  ::Config.Developer.AddRecentlyEditedScenario(c4sfile.getData());
377  // Open game
378  Application.OpenGame(c4sfile.getData());
379  return true;
380 }
const DWORD OFN_EXPLORER
Definition: C4ConsoleGUI.h:31
void OpenGame(const char *scenario=nullptr)
C4Config Config
Definition: C4Config.cpp:833
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:257
C4Game Game
Definition: C4Globals.cpp:52
size_t SLen(const char *sptr)
Definition: Standard.h:74
#define FILE_SELECT_FILTER_FOR_C4S
Definition: C4Console.cpp:38
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:96
const DWORD OFN_FILEMUSTEXIST
Definition: C4ConsoleGUI.h:28
C4ConfigDeveloper Developer
Definition: C4Config.h:252
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:26
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:684
char PlayerFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:104
void ClearCommandLine()
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:389
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:29
#define DirSep
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:557
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileQuit ( )

Definition at line 443 of file C4Console.cpp.

References Close().

Referenced by ConsoleDlgProc().

444 {
445  Close();
446  return true;
447 }
void Close() override
Definition: C4Console.cpp:437

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileRecord ( )

Definition at line 394 of file C4Console.cpp.

References Control, Game, C4Game::IsRunning, C4GameControl::IsRuntimeRecordPossible(), C4ConsoleGUI::RecordingEnabled(), and C4GameControl::RequestRuntimeRecord().

Referenced by ConsoleDlgProc(), and C4AppDelegate::record:.

395 {
396  // only in running mode
397  if (!Game.IsRunning || !::Control.IsRuntimeRecordPossible()) return false;
398  // start record!
400  // disable menuitem
402  return true;
403 }
bool IsRunning
Definition: C4Game.h:139
C4Game Game
Definition: C4Globals.cpp:52
C4GameControl Control
bool IsRuntimeRecordPossible() const
void RecordingEnabled()
Definition: C4Console.cpp:688
void RequestRuntimeRecord()

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileSave ( )

Definition at line 262 of file C4Console.cpp.

References SaveScenario().

Referenced by ConsoleDlgProc(), and C4AppDelegate::saveScenario:.

263 {
264  // Save game
265  // FIXME: What about editing a savegame inplace? (Game.C4S.Head.SaveGame)
266  return SaveScenario(nullptr);
267 }
bool SaveScenario(const char *path, bool export_packed=false)
Definition: C4Console.cpp:151

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileSaveAs ( bool  fSaveGame,
bool  export_packed = false 
)

Definition at line 269 of file C4Console.cpp.

References C4ConfigDeveloper::AddRecentlyEditedScenario(), StdStrBuf::Append(), Config, StdStrBuf::Copy(), DefaultExtension(), C4Config::Developer, FileSelect(), Game, StdStrBuf::getData(), C4Group::GetName(), OpenFileFlags::OFN_HIDEREADONLY, OpenFileFlags::OFN_OVERWRITEPROMPT, RemoveExtension(), SaveGame(), SaveScenario(), and C4Game::ScenarioFile.

Referenced by ConsoleDlgProc(), C4AppDelegate::saveGameAs:, and C4AppDelegate::saveScenarioAs:.

270 {
271  // Do save-as dialog
272  StdCopyStrBuf filename("");
273  filename.Copy(Game.ScenarioFile.GetName());
274  if (export_packed)
275  {
276  RemoveExtension(&filename);
277  filename.Append("_packed.ocs");
278  }
279  if (!FileSelect(&filename,
280  "OpenClonk Scenario\0*.ocs\0\0",
282  true)) return false;
283  DefaultExtension(&filename,"ocs");
284  if (!export_packed) ::Config.Developer.AddRecentlyEditedScenario(filename.getData());
285  if (fSaveGame)
286  // Save game
287  return SaveGame(filename.getData());
288  else
289  return SaveScenario(filename.getData(), export_packed);
290 }
C4Config Config
Definition: C4Config.cpp:833
C4Game Game
Definition: C4Globals.cpp:52
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:96
const char * GetName() const
Definition: C4Group.cpp:1845
C4Group ScenarioFile
Definition: C4Game.h:86
C4ConfigDeveloper Developer
Definition: C4Config.h:252
void DefaultExtension(char *szFilename, const char *szExtension)
Definition: StdFile.cpp:274
void RemoveExtension(char *szFilename)
Definition: StdFile.cpp:306
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:26
bool SaveScenario(const char *path, bool export_packed=false)
Definition: C4Console.cpp:151
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:389
bool SaveGame(const char *path)
Definition: C4Console.cpp:127
const DWORD OFN_OVERWRITEPROMPT
Definition: C4ConsoleGUI.h:27

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileSelect ( StdStrBuf sFilename,
const char *  szFilter,
DWORD  dwFlags,
bool  fSave = false 
)

Definition at line 389 of file C4Console.cpp.

References C4ConsoleGUI::FileSelect().

Referenced by FileOpen(), FileOpenWPlrs(), FileSaveAs(), and PlayerJoin().

390 {
391  return C4ConsoleGUI::FileSelect(sFilename, szFilter, dwFlags, fSave);
392 }
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave)
Definition: C4Console.cpp:682

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Window::FlashWindow ( )
inherited

Definition at line 74 of file C4AppMac.mm.

Referenced by C4AbstractApp::NotifyUserIfInactive().

75 {
76  [NSApp requestUserAttention:NSCriticalRequest];
77 }

Here is the caller graph for this function:

std::list< const char * > C4Console::GetScriptSuggestions ( class C4PropList target,
RecentScriptInputLists  section 
) const

Definition at line 622 of file C4Console.cpp.

References C4AulScriptEngine::GetFunctionNames(), and ScriptEngine.

Referenced by UpdateInputCtrl().

623 {
624  // Functions for this object
625  std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(target);
626  // Prepend most recently used script calls in reverse order
627  const std::list<StdCopyStrBuf> &mru = recent_script_input[section];
628  if (!mru.empty())
629  {
630  functions.insert(functions.begin(), nullptr);
631  // add pointers into string buffer list
632  // do not iterate with for (auto i : mru) because this would copy the buffer and add stack pointers
633  for (const auto & i : mru)
634  functions.insert(functions.begin(), i.getData());
635  }
636  return functions;
637 }
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
std::list< const char * > GetFunctionNames(C4PropList *)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Window::GetSize ( C4Rect pRect)
inherited

Definition at line 105 of file C4AppT.cpp.

Referenced by C4Application::OnResolutionChanged(), C4GUI::DialogWindow::PerformUpdate(), and C4Game::PreInit().

105 {return false;}

Here is the caller graph for this function:

void C4Window::GrabMouse ( bool  grab)
inherited

Definition at line 104 of file C4AppT.cpp.

Referenced by C4Application::GameTick().

104 {}

Here is the caller graph for this function:

void C4Console::HelpAbout ( )

Definition at line 449 of file C4Console.cpp.

References StdStrBuf::Format(), and C4ConsoleGUI::ShowAboutWithCopyright().

Referenced by ConsoleDlgProc(), and C4AppDelegate::showAbout:.

450 {
451  StdStrBuf strCopyright;
452  strCopyright.Format("Copyright (c) %s %s", C4COPYRIGHT_YEAR, C4COPYRIGHT_COMPANY);
453  ShowAboutWithCopyright(strCopyright);
454 }
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
void ShowAboutWithCopyright(StdStrBuf &copyright)
Definition: C4Console.cpp:692

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::In ( const char *  szText)

Definition at line 65 of file C4Console.cpp.

References C4Window::Active, CDT_Decide, CID_Script, Control, C4GameControl::DoInput(), EditCursor, C4EditCursor::EditingOK(), C4Network2::isEnabled(), C4Network2Status::isPastLobby(), MessageInput, Network, C4MessageInput::ProcessCommand(), C4MessageInput::ProcessInput(), C4ControlScript::SCOPE_Console, and C4Network2::Status.

Referenced by ConsoleDlgProc().

66 {
67  if (!Active || !szText) return false;
68  // begins with '/'? then it's a command
69  if (*szText == '/')
70  {
72  // done
73  return true;
74  }
75  // begins with '#'? then it's a message. Route via ProcessInput to allow #/sound
76  // Also, in the lobby, everything written here is still a message
77  bool is_chat_command = (*szText == '#');
78  if (is_chat_command || (::Network.isEnabled() && !::Network.Status.isPastLobby()))
79  {
80  ::MessageInput.ProcessInput(szText + is_chat_command);
81  return true;
82  }
83  // editing enabled?
84  if (!EditCursor.EditingOK()) return false;
85  // pass through network queue
87  return true;
88 }
C4EditCursor EditCursor
Definition: C4Console.h:90
C4MessageInput MessageInput
C4Network2 Network
Definition: C4Globals.cpp:53
bool isPastLobby() const
Definition: C4Network2.h:88
C4GameControl Control
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery)
bool ProcessCommand(const char *szCommand)
C4Network2Status Status
Definition: C4Network2.h:122
bool isEnabled() const
Definition: C4Network2.h:203
bool Active
Definition: C4Window.h:273
bool EditingOK(bool for_landscape_drawing=false)
bool ProcessInput(const char *szText)

Here is the call graph for this function:

Here is the caller graph for this function:

C4Window * C4Console::Init ( C4AbstractApp app)
virtual

Definition at line 58 of file C4Console.cpp.

References C4ConsoleGUI::CreateConsoleWindow().

Referenced by C4Application::DoInit().

59 {
61  return nullptr;
62  return this;
63 }
bool CreateConsoleWindow(C4AbstractApp *application)
Definition: C4Console.cpp:671

Here is the call graph for this function:

Here is the caller graph for this function:

C4Window * C4Window::Init ( C4Window::WindowKind  windowKind,
C4AbstractApp pApp,
const char *  Title,
const C4Rect size 
)
protectedvirtualinherited

Definition at line 106 of file C4AppT.cpp.

Referenced by C4ConsoleGUIPreviewWindow::C4ConsoleGUIPreviewWindow(), C4ConsoleGUI::CreateConsoleWindow(), C4ViewportWindow::Init(), and C4GUI::DialogWindow::Init().

106 {return this;}

Here is the caller graph for this function:

void C4Console::InitGame ( )

Definition at line 590 of file C4Console.cpp.

References C4Window::Active, C4ViewportList::CreateViewport(), Default(), EditCursor, C4ConsoleGUI::EnableControls(), C4ConsoleGUI::fGameOpen, Game, C4PlayerInfoList::GetStartupCount(), C4EditCursor::Init(), NO_OWNER, C4Game::PlayerInfos, C4Game::ScenarioFilename, SetCaptionToFilename(), UpdateInputCtrl(), UpdatePlayerMenu(), UpdateViewportMenu(), and Viewports.

Referenced by C4Game::Init().

591 {
592  if (!Active) return;
593  // Default game dependent members
594  Default();
596  // Init game dependent members
597  EditCursor.Init();
598 
599  // Console updates
600  fGameOpen=true;
601  UpdateInputCtrl();
605  // Initial neutral viewport unless started with players
607 }
C4EditCursor EditCursor
Definition: C4Console.h:90
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:143
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:102
C4Game Game
Definition: C4Globals.cpp:52
void UpdateInputCtrl()
Definition: C4Console.cpp:481
void SetCaptionToFilename(const char *szFilename)
Definition: C4Console.cpp:575
const int NO_OWNER
Definition: C4Constants.h:137
bool CreateViewport(int32_t iPlayer, bool fSilent=false)
Definition: C4Viewport.cpp:917
int32_t GetStartupCount()
void Default()
Definition: C4Console.cpp:411
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:71
bool UpdatePlayerMenu()
Definition: C4Console.cpp:488
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
bool Active
Definition: C4Window.h:273
bool UpdateViewportMenu()
Definition: C4Console.cpp:462

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::Message ( const char *  szMessage,
bool  fQuery = false 
)

Definition at line 292 of file C4Console.cpp.

References C4Window::Active, and C4ConsoleGUI::Message().

Referenced by C4EditCursor::EditingOK(), C4Game::InitPlayers(), C4EditCursor::LeftButtonDown(), SaveGame(), SaveScenario(), C4ToolsDlg::SetLandscapeMode(), C4EditCursor::ToolFailure(), and ViewportWinProc().

293 {
294  if (!Active) return false;
295  return C4ConsoleGUI::Message(szMessage, fQuery);
296 }
bool Message(const char *message, bool query)
Definition: C4Console.cpp:683
bool Active
Definition: C4Window.h:273

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::OnObjectSelectionChanged ( class C4EditCursorSelection selection)
inlineinherited

Definition at line 112 of file C4ConsoleGUI.h.

112 { }
void C4ConsoleGUI::OnStartGame ( )
inlineinherited

Definition at line 114 of file C4ConsoleGUI.h.

Referenced by C4Application::GameTick().

114 { }

Here is the caller graph for this function:

void C4ConsoleGUI::Out ( const char *  message)
inherited

Definition at line 684 of file C4Console.cpp.

Referenced by C4Game::DropDef(), C4Game::DropFile(), Log(), C4Application::ProcessCallback(), SaveGame(), and SaveScenario().

684 {}

Here is the caller graph for this function:

void C4Window::PerformUpdate ( )
virtualinherited

Reimplemented in C4GUI::DialogWindow, C4FullScreen, and C4ViewportWindow.

Definition at line 85 of file C4App.cpp.

86 {
87 }
void C4Console::PlayerJoin ( )

Definition at line 513 of file C4Console.cpp.

References StdStrBuf::Append(), StdStrBuf::AppendBackslash(), StdStrBuf::Copy(), DirectoryExists(), FileSelect(), StdStrBuf::getData(), C4PlayerList::JoinNew(), OpenFileFlags::OFN_ALLOWMULTISELECT, OpenFileFlags::OFN_EXPLORER, OpenFileFlags::OFN_HIDEREADONLY, Players, and SLen().

Referenced by ConsoleDlgProc(), and C4AppDelegate::joinPlayer:.

514 {
515  // Get player file name(s)
516  StdCopyStrBuf c4pfile("");
517  if (!FileSelect(&c4pfile,
518  "OpenClonk Player\0*.ocp\0\0",
520  )) return;
521 
522  // Multiple players
523  if (DirectoryExists(c4pfile.getData()))
524  {
525  const char *cptr = c4pfile.getData() + SLen(c4pfile.getData()) + 1;
526  while (*cptr)
527  {
528  StdStrBuf f;
529  f.Copy(c4pfile.getData());
530  f.AppendBackslash(); f.Append(cptr);
531  cptr += SLen(cptr)+1;
533  }
534  }
535  // Single player
536  else
537  {
538  ::Players.JoinNew(c4pfile.getData());
539  }
540 }
const char * getData() const
Definition: StdBuf.h:442
const DWORD OFN_EXPLORER
Definition: C4ConsoleGUI.h:31
size_t SLen(const char *sptr)
Definition: Standard.h:74
void AppendBackslash()
Definition: StdBuf.cpp:248
void JoinNew(const char *szFilename)
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
C4PlayerList Players
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:26
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:684
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:389
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:29
void Copy()
Definition: StdBuf.h:467

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::PropertyDlgClose ( )
inherited

Definition at line 686 of file C4Console.cpp.

Referenced by Clear(), PropertyDlgProc(), and C4EditCursor::SetMode().

686 {}

Here is the caller graph for this function:

bool C4ConsoleGUI::PropertyDlgOpen ( )
inherited

Definition at line 685 of file C4Console.cpp.

Referenced by C4EditCursor::OpenPropTools().

685 {return false;}

Here is the caller graph for this function:

void C4ConsoleGUI::PropertyDlgUpdate ( class C4EditCursorSelection rSelection,
bool  force_function_update 
)
inherited

Definition at line 687 of file C4Console.cpp.

Referenced by C4EditCursor::Clear(), C4EditCursor::Execute(), C4EditCursor::In(), C4EditCursor::OnSelectionChanged(), and C4EditCursor::OpenPropTools().

687 {}

Here is the caller graph for this function:

void C4ConsoleGUI::RecordingEnabled ( )
inherited

Definition at line 688 of file C4Console.cpp.

Referenced by FileRecord().

688 {}

Here is the caller graph for this function:

void C4Console::RegisterRecentInput ( const char *  input,
RecentScriptInputLists  section 
)

Definition at line 639 of file C4Console.cpp.

References Config, C4Config::Developer, and C4ConfigDeveloper::MaxScriptMRU.

Referenced by ConsoleDlgProc(), and C4EditCursor::In().

640 {
641  std::list<StdCopyStrBuf> &mru = recent_script_input[section];
642  // remove previous copy (i.e.: Same input just gets pushed to top)
643  mru.remove(StdCopyStrBuf(input));
644  // register to list
645  mru.emplace_back(input);
646  // limit history length
647  if (static_cast<int32_t>(mru.size()) > ::Config.Developer.MaxScriptMRU)
648  mru.erase(mru.begin());
649 }
C4Config Config
Definition: C4Config.cpp:833
int32_t MaxScriptMRU
Definition: C4Config.h:86
C4ConfigDeveloper Developer
Definition: C4Config.h:252

Here is the caller graph for this function:

bool C4Window::ReInit ( C4AbstractApp pApp)
virtualinherited

Definition at line 107 of file C4AppT.cpp.

107 {return false;}
void C4ConsoleGUI::RemoveViewport ( C4ViewportWindow cvp)
inlineinherited

Definition at line 111 of file C4ConsoleGUI.h.

111 { }
void C4Window::RequestUpdate ( )
virtualinherited

Definition at line 109 of file C4AppT.cpp.

Referenced by C4FullScreen::Execute().

109 {}

Here is the caller graph for this function:

bool C4Window::RestorePosition ( const char *  szWindowName,
const char *  szSubKey,
bool  fHidden = false 
)
inherited

Definition at line 108 of file C4AppT.cpp.

Referenced by C4ViewportWindow::Init(), and C4GUI::DialogWindow::Init().

108 {return false;}

Here is the caller graph for this function:

bool C4Console::SaveGame ( const char *  path)

Definition at line 127 of file C4Console.cpp.

References C4ConsoleGUI::CURSOR_Normal, C4ConsoleGUI::CURSOR_Wait, C4Network2::isEnabled(), C4Network2::isHost(), LoadResStr(), Message(), Network, C4ConsoleGUI::Out(), C4GameSave::Save(), and C4ConsoleGUI::SetCursor().

Referenced by FileSaveAs().

128 {
129  // Network hosts only
130  if (::Network.isEnabled() && !::Network.isHost())
131  { Message(LoadResStr("IDS_GAME_NOCLIENTSAVE")); return false; }
132 
133  // Save game to open scenario file
134  bool fOkay=true;
136 
137  C4GameSave *pGameSave = new C4GameSaveSavegame();
138  if (!pGameSave->Save(path))
139  { Out("Save failed"); fOkay=false; }
140  delete pGameSave;
141 
143 
144  // Status report
145  if (!fOkay) Message(LoadResStr("IDS_CNS_SAVERROR"));
146  else Out(LoadResStr("IDS_CNS_GAMESAVED"));
147 
148  return fOkay;
149 }
bool isHost() const
Definition: C4Network2.h:209
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
bool Save(const char *szFilename)
Definition: C4GameSave.cpp:398
void Out(const char *message)
Definition: C4Console.cpp:684
bool isEnabled() const
Definition: C4Network2.h:203
void SetCursor(Cursor cursor)
Definition: C4Console.cpp:690
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:292

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::SaveScenario ( const char *  path,
bool  export_packed = false 
)

Definition at line 151 of file C4Console.cpp.

References _MAX_PATH, C4Window::Active, C4Group_CopyItem(), C4Group_PackDirectoryTo(), C4Group::Close(), Console, C4ConsoleGUI::CURSOR_Normal, C4ConsoleGUI::CURSOR_Wait, EraseItem(), Exact, FileExists(), StdStrBuf::Format(), FormatString(), C4Game::fScriptCreatedObjects, Game, StdStrBuf::getData(), GetFilename(), C4Landscape::GetMode(), C4Group::GetMother(), C4Group::GetName(), C4Group::IsPacked(), ItemIdentical(), Landscape, LoadResStr(), Message(), C4Group::Open(), C4ConsoleGUI::Out(), C4GameSave::Save(), C4Game::ScenarioFile, C4Game::ScenarioFilename, SCopy(), SEqual2(), SetCaptionToFilename(), C4ConsoleGUI::SetCursor(), and C4Game::TempScenarioFile.

Referenced by FileSave(), and FileSaveAs().

152 {
153  C4Group *save_target_group = &Game.ScenarioFile;
154  C4Group export_group;
155  if (export_packed)
156  {
157  // Export to packed file: Delete existing
158  if (FileExists(path))
159  {
160  if (ItemIdentical(Game.ScenarioFilename, path) || !EraseItem(path))
161  {
162  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), path).getData());
163  return false;
164  }
165  }
166  // Write into new, packed copy
167  if (!C4Group_PackDirectoryTo(Game.ScenarioFilename, path) || !export_group.Open(path))
168  {
169  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), path).getData());
170  return false;
171  }
172  save_target_group = &export_group;
173  }
174  else if (path)
175  {
176  // When trying to save into a subfolder of the existing scenario, the copy function
177  // below will try to recursively copy everything until it blows the stack. There is
178  // really no good reason to do this, so we just disallow it here.
179  if (SEqual2(path, Game.ScenarioFilename))
180  {
181  Message(LoadResStr("IDS_CNS_RECURSIVESAVEASERROR"));
182  return false;
183  }
184  // Open new scenario file
185  // Close current scenario file to allow re-opening at new path
187  // Copy current scenario file to target
189  {
190  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"),path).getData());
191  return false;
192  }
193  // Re-open at new path (unless exporting, in which case the export is just a copy)
197  {
198  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), Game.ScenarioFilename).getData());
199  return false;
200  }
201  }
202  else
203  {
204  // Do not save to temp network file
206  {
207  Message(LoadResStr("IDS_CNS_NONETREFSAVE"));
208  return false;
209  }
210  }
211 
212  // Can't save to child groups
213  if (save_target_group->GetMother() && save_target_group->GetMother()->IsPacked())
214  {
215  StdStrBuf str;
216  str.Format(LoadResStr("IDS_CNS_NOCHILDSAVE"),
217  GetFilename(save_target_group->GetName()));
218  Message(str.getData());
219  return false;
220  }
221 
222  // Save game to open scenario file
224 
225  bool fOkay=true;
227  if (!pGameSave->Save(*save_target_group, false))
228  { Out("Game::Save failed"); fOkay=false; }
229  delete pGameSave;
230 
231  // Close and reopen scenario file to fix file changes
232  if (!export_packed)
233  {
234  if (!Game.ScenarioFile.Close())
235  {
236  Out("ScenarioFile::Close failed"); fOkay = false;
237  }
239  {
240  Out("ScenarioFile::Open failed"); fOkay = false;
241  }
242  }
243 
245 
246  // Initialize/script notification
248  {
249  StdStrBuf str(LoadResStr("IDS_CNS_SCRIPTCREATEDOBJECTS"));
250  str += LoadResStr("IDS_CNS_WARNDOUBLE");
251  Message(str.getData());
252  Game.fScriptCreatedObjects = false;
253  }
254 
255  // Status report
256  if (!fOkay) Message(LoadResStr("IDS_CNS_SAVERROR"));
257  else Out(LoadResStr("IDS_CNS_SCENARIOSAVED"));
258 
259  return fOkay;
260 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:45
const char * getData() const
Definition: StdBuf.h:442
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:102
StdStrBuf TempScenarioFile
Definition: C4Game.h:126
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
C4Console Console
Definition: C4Globals.cpp:45
C4Group * GetMother()
Definition: C4Group.cpp:2004
bool ItemIdentical(const char *szFilename1, const char *szFilename2)
Definition: StdFile.cpp:855
C4Game Game
Definition: C4Globals.cpp:52
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
#define _MAX_PATH
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool C4Group_PackDirectoryTo(const char *szFilename, const char *szFilenameTo)
Definition: C4Group.cpp:221
bool Save(const char *szFilename)
Definition: C4GameSave.cpp:398
const char * GetName() const
Definition: C4Group.cpp:1845
C4Landscape Landscape
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
void SetCaptionToFilename(const char *szFilename)
Definition: C4Console.cpp:575
C4Group ScenarioFile
Definition: C4Game.h:86
bool C4Group_CopyItem(const char *szSource, const char *szTarget1, bool fNoSort, bool fResetAttributes)
Definition: C4Group.cpp:100
void Out(const char *message)
Definition: C4Console.cpp:684
bool Close()
Definition: C4Group.cpp:755
LandscapeMode GetMode() const
bool FileExists(const char *szFileName)
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:809
bool Active
Definition: C4Window.h:273
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:198
bool IsPacked() const
Definition: C4Group.cpp:2009
bool fScriptCreatedObjects
Definition: C4Game.h:117
void SetCursor(Cursor cursor)
Definition: C4Console.cpp:690
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:292
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::SetCaptionToFilename ( const char *  szFilename)

Definition at line 575 of file C4Console.cpp.

References GetFilename(), C4ConsoleGUI::SetCaptionToFileName(), and C4Window::SetTitle().

Referenced by InitGame(), and SaveScenario().

576 {
577  SetTitle(GetFilename(szFilename));
579 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:45
void SetCaptionToFileName(const char *file_name)
Definition: C4Console.cpp:689
void SetTitle(const char *Title)
Definition: C4AppT.cpp:111

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::SetCaptionToFileName ( const char *  file_name)
inherited

Definition at line 689 of file C4Console.cpp.

Referenced by SetCaptionToFilename().

689 {}

Here is the caller graph for this function:

void C4ConsoleGUI::SetCursor ( C4ConsoleGUI::Cursor  cursor)
inherited

Definition at line 690 of file C4Console.cpp.

Referenced by SaveGame(), and SaveScenario().

690 {}

Here is the caller graph for this function:

void C4ConsoleGUI::SetInputFunctions ( std::list< const char * > &  functions)
inherited

Definition at line 691 of file C4Console.cpp.

Referenced by UpdateInputCtrl().

691 {}

Here is the caller graph for this function:

void C4Window::SetSize ( unsigned int  cx,
unsigned int  cy 
)
inherited

Definition at line 110 of file C4AppT.cpp.

Referenced by C4Application::DoInit(), C4GUI::DialogWindow::Init(), C4AbstractApp::SetVideoMode(), and C4GUI::Dialog::UpdateSize().

110 {}

Here is the caller graph for this function:

void C4Window::SetTitle ( const char *  Title)
inherited

Definition at line 111 of file C4AppT.cpp.

Referenced by CloseGame(), SetCaptionToFilename(), and C4GUI::Dialog::SetTitle().

111 {}

Here is the caller graph for this function:

void C4ConsoleGUI::ShowAboutWithCopyright ( StdStrBuf copyright)
inherited

Definition at line 692 of file C4Console.cpp.

Referenced by HelpAbout().

692 {}

Here is the caller graph for this function:

bool C4Window::StorePosition ( const char *  szWindowName,
const char *  szSubKey,
bool  fStoreSize = true 
)
inherited

Definition at line 139 of file C4WindowSDL.cpp.

139 { return true; }
bool C4Console::TogglePause ( )

Definition at line 617 of file C4Console.cpp.

References Game, and C4Game::TogglePause().

Referenced by C4Game::InitKeyboard().

618 {
619  return Game.TogglePause();
620 }
C4Game Game
Definition: C4Globals.cpp:52
bool TogglePause()
Definition: C4Game.cpp:942

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgClose ( )
inherited

Definition at line 666 of file C4Console.cpp.

Referenced by C4ToolsDlg::Clear(), and C4EditCursor::SetMode().

666 {}

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgInitMaterialCtrls ( class C4ToolsDlg dlg)
inherited

Definition at line 693 of file C4Console.cpp.

Referenced by C4ToolsDlg::InitMaterialCtrls().

693 {}

Here is the caller graph for this function:

bool C4ConsoleGUI::ToolsDlgOpen ( class C4ToolsDlg dlg)
inherited

Definition at line 694 of file C4Console.cpp.

Referenced by C4ToolsDlg::Open().

694 {return false;}

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgSelectBackMaterial ( C4ToolsDlg dlg,
const char *  material 
)
inherited

Definition at line 697 of file C4Console.cpp.

Referenced by C4ToolsDlg::SelectBackMaterial().

697 {}

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgSelectBackTexture ( C4ToolsDlg dlg,
const char *  texture 
)
inherited

Definition at line 698 of file C4Console.cpp.

Referenced by C4ToolsDlg::SelectBackTexture(), and C4ToolsDlg::SetBackTexture().

698 {}

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgSelectMaterial ( C4ToolsDlg dlg,
const char *  material 
)
inherited

Definition at line 695 of file C4Console.cpp.

Referenced by C4ToolsDlg::SelectMaterial().

695 {}

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgSelectTexture ( C4ToolsDlg dlg,
const char *  texture 
)
inherited

Definition at line 696 of file C4Console.cpp.

Referenced by C4ToolsDlg::SelectTexture(), and C4ToolsDlg::SetTexture().

696 {}

Here is the caller graph for this function:

bool C4ConsoleGUI::UpdateHaltCtrls ( bool  fHalt)
inlineinherited

Definition at line 152 of file C4ConsoleGUI.h.

References C4Window::Active, and C4ConsoleGUI::DoUpdateHaltCtrls().

Referenced by C4Network2::CheckStatusReached(), C4Game::InitGameFinal(), C4Network2::OnStatusAck(), C4Network2::OnStatusReached(), C4Game::Pause(), and C4Game::Unpause().

153  {
154  if (!Active)
155  return false;
156  DoUpdateHaltCtrls(fHalt);
157  return true;
158  }
bool DoUpdateHaltCtrls(bool fHalt)
Definition: C4Console.cpp:681
bool Active
Definition: C4Window.h:273

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::UpdateInputCtrl ( )

Definition at line 481 of file C4Console.cpp.

References C4Value::_getPropList(), Console, GameScript, GetScriptSuggestions(), MRU_Scenario, C4GameScriptHost::ScenPropList, and C4ConsoleGUI::SetInputFunctions().

Referenced by ConsoleDlgProc(), and InitGame().

482 {
483  // add global and standard functions
485  SetInputFunctions(functions);
486 }
C4Console Console
Definition: C4Globals.cpp:45
C4GameScriptHost GameScript
C4Value ScenPropList
Definition: C4ScriptHost.h:163
std::list< const char * > GetScriptSuggestions(class C4PropList *target, RecentScriptInputLists section) const
Definition: C4Console.cpp:622
void SetInputFunctions(std::list< const char * > &functions)
Definition: C4Console.cpp:691
C4PropList * _getPropList() const
Definition: C4Value.h:129

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::UpdateMenus ( )

Definition at line 504 of file C4Console.cpp.

References C4Window::Active, C4ConsoleGUI::EnableControls(), C4ConsoleGUI::fGameOpen, UpdateNetMenu(), UpdatePlayerMenu(), and UpdateViewportMenu().

Referenced by C4Network2::DoLobby(), C4Game::JoinPlayer(), and C4PlayerList::Remove().

505 {
506  if (!Active) return;
510  UpdateNetMenu();
511 }
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:143
void UpdateNetMenu()
Definition: C4Console.cpp:542
bool UpdatePlayerMenu()
Definition: C4Console.cpp:488
bool Active
Definition: C4Window.h:273
bool UpdateViewportMenu()
Definition: C4Console.cpp:462

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ConsoleGUI::UpdateModeCtrls ( int  iMode)
inherited

Definition at line 699 of file C4Console.cpp.

Referenced by C4EditCursor::Init(), and C4EditCursor::SetMode().

699 {return false;}

Here is the caller graph for this function:

void C4Console::UpdateNetMenu ( )

Definition at line 542 of file C4Console.cpp.

References C4Window::Active, C4ConsoleGUI::AddNetMenu(), C4ConsoleGUI::AddNetMenuItemForPlayer(), ClearNetMenu(), C4Game::Clients, C4Network2::Clients, C4ConsoleGUI::CO_Activate, C4ConsoleGUI::CO_Deactivate, C4ConsoleGUI::CO_Kick, C4ConsoleGUI::CO_None, StdStrBuf::Format(), Game, StdStrBuf::getData(), C4ClientList::getLocalID(), C4ClientList::getLocalName(), C4Network2ClientList::GetNextClient(), C4Network2::isEnabled(), C4Network2::isHost(), LoadResStr(), and Network.

Referenced by UpdateMenus().

543 {
544  // Active & network hosting check
545  if (!Active) return;
546  if (!::Network.isHost() || !::Network.isEnabled()) return;
547  // Clear old
548  ClearNetMenu();
549  // Insert menu
551 
552  // Host
553  StdStrBuf str;
554  str.Format(LoadResStr("IDS_MNU_NETHOST"),Game.Clients.getLocalName(),Game.Clients.getLocalID());
556  // Clients
557  for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
558  {
559  if (pClient->isHost()) continue;
560  str.Format(LoadResStr(pClient->isActivated() ? "IDS_MNU_NETCLIENT_DEACTIVATE" : "IDS_MNU_NETCLIENT_ACTIVATE"),
561  pClient->getName(), pClient->getID());
562  AddNetMenuItemForPlayer(pClient->getID(), str.getData(), pClient->isActivated() ? C4ConsoleGUI::CO_Deactivate : C4ConsoleGUI::CO_Activate);
563  str.Format(LoadResStr("IDS_NET_KICKCLIENTEX"), pClient->getName(), pClient->getID());
564  AddNetMenuItemForPlayer(pClient->getID(), str.getData(), C4ConsoleGUI::CO_Kick);
565  }
566  return;
567 }
const char * getData() const
Definition: StdBuf.h:442
bool isHost() const
Definition: C4Network2.h:209
C4Network2Client * GetNextClient(C4Network2Client *pClient)
void ClearNetMenu()
Definition: C4Console.cpp:569
C4Game Game
Definition: C4Globals.cpp:52
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
int32_t getLocalID() const
Definition: C4Client.h:171
const char * getLocalName() const
Definition: C4Client.h:170
bool isEnabled() const
Definition: C4Network2.h:203
void AddNetMenuItemForPlayer(int32_t client_id, const char *text, C4ConsoleGUI::ClientOperation co)
Definition: C4Console.cpp:664
C4Network2ClientList Clients
Definition: C4Network2.h:116
bool Active
Definition: C4Window.h:273
C4ClientList & Clients
Definition: C4Game.h:69
void AddNetMenu()
Definition: C4Console.cpp:665

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::UpdatePlayerMenu ( )

Definition at line 488 of file C4Console.cpp.

References C4Window::Active, C4ConsoleGUI::AddKickPlayerMenuItem(), C4ConsoleGUI::ClearPlayerMenu(), C4ConsoleGUI::Editing, C4PlayerList::First, StdStrBuf::Format(), C4Network2::isEnabled(), C4Network2::isHost(), LoadResStr(), Network, C4Player::Next, and Players.

Referenced by InitGame(), and UpdateMenus().

489 {
490  if (!Active) return false;
491  ClearPlayerMenu();
492  for (C4Player *pPlr=::Players.First; pPlr; pPlr=pPlr->Next)
493  {
494  StdStrBuf sText;
495  if (::Network.isEnabled())
496  sText.Format(LoadResStr("IDS_CNS_PLRQUITNET"),pPlr->GetName(),pPlr->AtClientName);
497  else
498  sText.Format(LoadResStr("IDS_CNS_PLRQUIT"),pPlr->GetName());
499  AddKickPlayerMenuItem(pPlr, sText, (!::Network.isEnabled() || ::Network.isHost()) && Editing);
500  }
501  return true;
502 }
bool isHost() const
Definition: C4Network2.h:209
C4Player * First
Definition: C4PlayerList.h:31
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
C4PlayerList Players
bool isEnabled() const
Definition: C4Network2.h:203
void AddKickPlayerMenuItem(C4Player *player, StdStrBuf &player_text, bool enabled)
Definition: C4Console.cpp:662
bool Active
Definition: C4Window.h:273
C4Player * Next
Definition: C4Player.h:142
void ClearPlayerMenu()
Definition: C4Console.cpp:669

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::UpdateStatusBars ( )

Definition at line 105 of file C4Console.cpp.

References C4Window::Active, C4ConsoleGUI::CONSOLE_FrameCounter, C4ConsoleGUI::CONSOLE_TimeFPS, C4ConsoleGUI::DisplayInfoText(), StdStrBuf::Format(), FPS, C4Game::FPS, FrameCounter, C4Game::FrameCounter, Game, Time, and C4Game::Time.

Referenced by Execute().

106 {
107  if (!Active) return;
108  // Frame counter
110  {
112  StdStrBuf str;
113  str.Format("Frame: %i",FrameCounter);
115  }
116  // Time & FPS
117  if ((Game.Time!=Time) || (Game.FPS!=FPS))
118  {
119  Time=Game.Time;
120  FPS=Game.FPS;
121  StdStrBuf str;
122  str.Format("%02d:%02d:%02d (%i FPS)",Time/3600,(Time%3600)/60,Time%60,FPS);
124  }
125 }
int FrameCounter
Definition: C4Console.h:92
C4Game Game
Definition: C4Globals.cpp:52
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
int Time
Definition: C4Console.h:93
int32_t FrameCounter
Definition: C4Game.h:128
int32_t FPS
Definition: C4Game.h:111
int32_t Time
Definition: C4Game.h:131
int FPS
Definition: C4Console.h:93
bool Active
Definition: C4Window.h:273
void DisplayInfoText(InfoTextType type, StdStrBuf &text)
Definition: C4Console.cpp:679

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::UpdateViewportMenu ( )

Definition at line 462 of file C4Console.cpp.

References C4Window::Active, C4ConsoleGUI::AddMenuItemForPlayer(), ClearViewportMenu(), C4PlayerList::First, StdStrBuf::Format(), LoadResStr(), C4Player::Next, and Players.

Referenced by InitGame(), and UpdateMenus().

463 {
464  if (!Active) return false;
466  for (C4Player *pPlr=::Players.First; pPlr; pPlr=pPlr->Next)
467  {
468  StdStrBuf sText;
469  sText.Format(LoadResStr("IDS_CNS_NEWPLRVIEWPORT"),pPlr->GetName());
471  }
472  return true;
473 }
void ClearViewportMenu()
Definition: C4Console.cpp:475
C4Player * First
Definition: C4PlayerList.h:31
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4PlayerList Players
bool Active
Definition: C4Window.h:273
C4Player * Next
Definition: C4Player.h:142
void AddMenuItemForPlayer(C4Player *player, StdStrBuf &player_text)
Definition: C4Console.cpp:663

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::ViewportNew ( )

Definition at line 456 of file C4Console.cpp.

References C4ViewportList::CreateViewport(), C4ConsoleGUI::fGameOpen, NO_OWNER, and Viewports.

Referenced by ConsoleDlgProc(), and C4AppDelegate::newViewport:.

457 {
458  if (!fGameOpen) return;
460 }
const int NO_OWNER
Definition: C4Constants.h:137
bool CreateViewport(int32_t iPlayer, bool fSilent=false)
Definition: C4Viewport.cpp:917
C4ViewportList Viewports
Definition: C4Viewport.cpp:841

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

bool C4ConsoleGUI::Editing
inherited
WindowKind C4Window::eKind
inherited

Definition at line 275 of file C4Window.h.

bool C4ConsoleGUI::fGameOpen
inherited

Definition at line 84 of file C4ConsoleGUI.h.

Referenced by C4Console(), CloseGame(), FileClose(), InitGame(), UpdateMenus(), and ViewportNew().

int C4Console::FPS

Definition at line 93 of file C4Console.h.

Referenced by UpdateStatusBars().

int C4Console::FrameCounter

Definition at line 92 of file C4Console.h.

Referenced by C4Console(), and UpdateStatusBars().

C4ObjectListDlg C4Console::ObjectListDlg

Definition at line 89 of file C4Console.h.

Referenced by Execute(), and C4EditCursor::OnSelectionChanged().

C4Object* C4ConsoleGUI::PropertyDlgObject
inherited

Definition at line 164 of file C4ConsoleGUI.h.

Referenced by Default().

int C4Console::Time

Definition at line 93 of file C4Console.h.

Referenced by UpdateStatusBars().


The documentation for this class was generated from the following files: