OpenClonk
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)
 
virtual C4WindowInit (WindowKind windowKind, C4AbstractApp *pApp, const char *Title, const C4Rect *size)
 
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, int min_expected=0) 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

◆ ClientOperation

Enumerator
CO_None 
CO_Deactivate 
CO_Activate 
CO_Kick 

Definition at line 70 of file C4ConsoleGUI.h.

71  {
72  CO_None,
75  CO_Kick
76  };

◆ Cursor

enum C4ConsoleGUI::Cursor
inherited
Enumerator
CURSOR_Normal 
CURSOR_Wait 

Definition at line 64 of file C4ConsoleGUI.h.

65  {
68  };

◆ InfoTextType

Enumerator
CONSOLE_Cursor 
CONSOLE_FrameCounter 
CONSOLE_TimeFPS 

Definition at line 50 of file C4ConsoleGUI.h.

51  {
55  };
@ CONSOLE_FrameCounter
Definition: C4ConsoleGUI.h:53

◆ RecentScriptInputLists

Enumerator
MRU_Scenario 
MRU_Object 

Definition at line 96 of file C4Console.h.

97  {
98  MRU_Scenario = 0,
99  MRU_Object = 1
100  };
@ MRU_Object
Definition: C4Console.h:99
@ MRU_Scenario
Definition: C4Console.h:98

◆ Stage

enum C4ConsoleGUI::Stage
inherited
Enumerator
STAGE_Start 
STAGE_Intermediate 
STAGE_End 

Definition at line 57 of file C4ConsoleGUI.h.

58  {
61  STAGE_End,
62  };

◆ WindowKind

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

Definition at line 263 of file C4Window.h.

264  {
265  W_GuiWindow,
266  W_Console,
267  W_Viewport,
268  W_Fullscreen,
269  W_Control // wrapper to a render target control inside a window
270  };
@ W_Fullscreen
Definition: C4Window.h:268
@ W_GuiWindow
Definition: C4Window.h:265
@ W_Control
Definition: C4Window.h:269
@ W_Viewport
Definition: C4Window.h:267
@ W_Console
Definition: C4Window.h:266

Constructor & Destructor Documentation

◆ C4Console()

C4Console::C4Console ( )

Definition at line 44 of file C4Console.cpp.

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:274

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

◆ ~C4Console()

C4Console::~C4Console ( )
overridedefault

Member Function Documentation

◆ AddKickPlayerMenuItem()

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

Definition at line 662 of file C4Console.cpp.

662 {}

Referenced by UpdatePlayerMenu().

Here is the caller graph for this function:

◆ AddMenuItemForPlayer()

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

Definition at line 663 of file C4Console.cpp.

663 {}

Referenced by UpdateViewportMenu().

Here is the caller graph for this function:

◆ AddNetMenu()

void C4ConsoleGUI::AddNetMenu ( )
inherited

Definition at line 665 of file C4Console.cpp.

665 {}

Referenced by UpdateNetMenu().

Here is the caller graph for this function:

◆ AddNetMenuItemForPlayer()

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

Definition at line 664 of file C4Console.cpp.

664 {}

Referenced by UpdateNetMenu().

Here is the caller graph for this function:

◆ AddViewport()

void C4ConsoleGUI::AddViewport ( C4ViewportWindow cvp)
inlineinherited

Definition at line 110 of file C4ConsoleGUI.h.

110 { }

◆ CharIn()

virtual void C4Window::CharIn ( const char *  )
inlinevirtualinherited

Reimplemented in C4FullScreen.

Definition at line 282 of file C4Window.h.

282 { }

◆ Clear()

void C4Console::Clear ( )
overridevirtual

Reimplemented from C4Window.

Definition at line 418 of file C4Console.cpp.

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 }
C4Application Application
Definition: C4Globals.cpp:44
void Quit() override
void ClearPlayerMenu()
Definition: C4Console.cpp:669
void DeleteConsoleWindow()
Definition: C4Console.cpp:678
void PropertyDlgClose()
Definition: C4Console.cpp:686
void ClearViewportMenu()
Definition: C4Console.cpp:475
C4EditCursor EditCursor
Definition: C4Console.h:90
void ClearNetMenu()
Definition: C4Console.cpp:569
C4ToolsDlg ToolsDlg
Definition: C4Console.h:88
C4Surface * pSurface
Definition: C4Window.h:275
virtual void Clear()
Definition: C4AppT.cpp:102

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

Referenced by C4Application::Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearLog()

bool C4ConsoleGUI::ClearLog ( )
inherited

Definition at line 667 of file C4Console.cpp.

667 {return false;}

Referenced by C4MessageInput::ProcessCommand().

Here is the caller graph for this function:

◆ ClearNetMenu()

void C4Console::ClearNetMenu ( )

Definition at line 569 of file C4Console.cpp.

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

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

Referenced by Clear(), and UpdateNetMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearPlayerMenu()

void C4ConsoleGUI::ClearPlayerMenu ( )
inherited

Definition at line 669 of file C4Console.cpp.

669 {}

Referenced by Clear(), and UpdatePlayerMenu().

Here is the caller graph for this function:

◆ ClearPointers()

void C4Console::ClearPointers ( C4Object pObj)

Definition at line 405 of file C4Console.cpp.

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

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

Referenced by C4Game::ClearPointers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearViewportMenu()

void C4Console::ClearViewportMenu ( )

Definition at line 475 of file C4Console.cpp.

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

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

Referenced by Clear(), and UpdateViewportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Close()

void C4Console::Close ( )
overridevirtual

Implements C4Window.

Definition at line 437 of file C4Console.cpp.

438 {
440  Application.Quit();
441 }
void CloseConsoleWindow()
Definition: C4ConsoleGUI.h:116

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

Referenced by ConsoleDlgProc(), and FileQuit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseConsoleWindow()

void C4ConsoleGUI::CloseConsoleWindow ( )
inlineinherited

Definition at line 116 of file C4ConsoleGUI.h.

116 {}

Referenced by Close().

Here is the caller graph for this function:

◆ CloseGame()

void C4Console::CloseGame ( )

Definition at line 609 of file C4Console.cpp.

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

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

Referenced by C4Game::Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateConsoleWindow()

bool C4ConsoleGUI::CreateConsoleWindow ( C4AbstractApp application)
inherited

Definition at line 671 of file C4Console.cpp.

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:28
virtual C4Window * Init(WindowKind windowKind, C4AbstractApp *pApp, const char *Title, const C4Rect *size)
Definition: C4AppT.cpp:109

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

Referenced by Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateNewScenario()

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

Definition at line 113 of file C4ConsoleGUI.h.

113 { return false; }

Referenced by FileNew().

Here is the caller graph for this function:

◆ Default()

void C4Console::Default ( )

Definition at line 411 of file C4Console.cpp.

412 {
414  PropertyDlgObject = nullptr;
415  ToolsDlg.Default();
416 }
C4Object * PropertyDlgObject
Definition: C4ConsoleGUI.h:164

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

Referenced by InitGame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteConsoleWindow()

void C4ConsoleGUI::DeleteConsoleWindow ( )
inherited

Definition at line 678 of file C4Console.cpp.

678 {}

Referenced by Clear().

Here is the caller graph for this function:

◆ DisplayInfoText()

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

Definition at line 679 of file C4Console.cpp.

679 {}

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

Here is the caller graph for this function:

◆ DoEnableControls()

void C4ConsoleGUI::DoEnableControls ( bool  fEnable)
inherited

Definition at line 680 of file C4Console.cpp.

680 {}

Referenced by C4ConsoleGUI::EnableControls().

Here is the caller graph for this function:

◆ DoHalt()

void C4Console::DoHalt ( )

Definition at line 100 of file C4Console.cpp.

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

References Game, and C4Game::Pause().

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoPlay()

void C4Console::DoPlay ( )

Definition at line 95 of file C4Console.cpp.

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

References Game, and C4Game::Unpause().

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoUpdateHaltCtrls()

bool C4ConsoleGUI::DoUpdateHaltCtrls ( bool  fHalt)
inherited

Definition at line 681 of file C4Console.cpp.

681 {return false;}

Referenced by C4ConsoleGUI::UpdateHaltCtrls().

Here is the caller graph for this function:

◆ EditGraphControl()

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

Definition at line 118 of file C4ConsoleGUI.h.

118 {}

◆ EnableControls()

void C4ConsoleGUI::EnableControls ( bool  fEnable)
inlineinherited

Definition at line 143 of file C4ConsoleGUI.h.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureDefinitionListInitialized()

void C4ConsoleGUI::EnsureDefinitionListInitialized ( )
inlineinherited

Definition at line 115 of file C4ConsoleGUI.h.

115 { }

◆ EnumerateMultiSamples()

void C4Window::EnumerateMultiSamples ( std::vector< int > &  samples,
int  min_expected = 0 
) const
virtualinherited

Definition at line 105 of file C4AppT.cpp.

105 {}

Referenced by C4StartupOptionsDlg::C4StartupOptionsDlg().

Here is the caller graph for this function:

◆ Execute()

void C4Console::Execute ( )

Definition at line 581 of file C4Console.cpp.

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

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

Referenced by C4Application::Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileClose()

bool C4Console::FileClose ( )

Definition at line 382 of file C4Console.cpp.

383 {
384  if (!fGameOpen) return false;
386  return true;
387 }

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

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileCommand()

bool C4Console::FileCommand ( )

◆ FileNew()

bool C4Console::FileNew ( )

Definition at line 298 of file C4Console.cpp.

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 }
C4Config Config
Definition: C4Config.cpp:930
void OpenGame(const char *scenario=nullptr)
void ClearCommandLine()
void AddRecentlyEditedScenario(const char *filename)
Definition: C4Config.cpp:97
C4ConfigDeveloper Developer
Definition: C4Config.h:256
bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network)
Definition: C4ConsoleGUI.h:113
bool NetworkActive
Definition: C4Game.h:123
bool fLobby
Definition: C4Game.h:119
const char * getData() const
Definition: StdBuf.h:442

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

Here is the call graph for this function:

◆ FileOpen()

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

Definition at line 319 of file C4Console.cpp.

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 }
#define FILE_SELECT_FILTER_FOR_C4S
Definition: C4Console.cpp:38
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:389
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:26
const DWORD OFN_FILEMUSTEXIST
Definition: C4ConsoleGUI.h:28

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileOpenWPlrs()

bool C4Console::FileOpenWPlrs ( )

Definition at line 343 of file C4Console.cpp.

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 }
#define DirSep
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:563
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:263
size_t SLen(const char *sptr)
Definition: Standard.h:74
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:708
char PlayerFilenames[20 *_MAX_PATH_LEN]
Definition: C4Game.h:104
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:29
const DWORD OFN_EXPLORER
Definition: C4ConsoleGUI.h:31

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileQuit()

bool C4Console::FileQuit ( )

Definition at line 443 of file C4Console.cpp.

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

References Close().

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileRecord()

bool C4Console::FileRecord ( )

Definition at line 394 of file C4Console.cpp.

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

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

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileSave()

bool C4Console::FileSave ( )

Definition at line 262 of file C4Console.cpp.

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

References SaveScenario().

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileSaveAs()

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

Definition at line 269 of file C4Console.cpp.

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 }
void DefaultExtension(char *szFilename, const char *szExtension)
Definition: StdFile.cpp:271
void RemoveExtension(char *szFilename)
Definition: StdFile.cpp:303
bool SaveGame(const char *path)
Definition: C4Console.cpp:127
C4Group ScenarioFile
Definition: C4Game.h:86
const char * GetName() const
Definition: C4Group.cpp:2309
const DWORD OFN_OVERWRITEPROMPT
Definition: C4ConsoleGUI.h:27

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileSelect()

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

Definition at line 389 of file C4Console.cpp.

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

References C4ConsoleGUI::FileSelect().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlashWindow()

void C4Window::FlashWindow ( )
inherited

Definition at line 75 of file C4AppMac.mm.

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

Referenced by C4AbstractApp::NotifyUserIfInactive().

Here is the caller graph for this function:

◆ GetScriptSuggestions()

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

Definition at line 622 of file C4Console.cpp.

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 *)
Definition: C4Aul.cpp:201

References C4AulScriptEngine::GetFunctionNames(), and ScriptEngine.

Referenced by UpdateInputCtrl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSize()

bool C4Window::GetSize ( C4Rect pRect)
inherited

Definition at line 108 of file C4AppT.cpp.

108 {return false;}

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

Here is the caller graph for this function:

◆ GrabMouse()

void C4Window::GrabMouse ( bool  grab)
inherited

Definition at line 107 of file C4AppT.cpp.

107 {}

Referenced by C4Application::GameTick().

Here is the caller graph for this function:

◆ HelpAbout()

void C4Console::HelpAbout ( )

Definition at line 449 of file C4Console.cpp.

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

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

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ In()

bool C4Console::In ( const char *  szText)

Definition at line 65 of file C4Console.cpp.

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 }
@ CDT_Decide
Definition: C4GameControl.h:39
C4Network2 Network
Definition: C4Globals.cpp:53
C4MessageInput MessageInput
@ CID_Script
Definition: C4PacketBase.h:154
bool EditingOK(bool for_landscape_drawing=false)
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery)
bool ProcessInput(const char *szText)
bool ProcessCommand(const char *szCommand)
C4Network2Status Status
Definition: C4Network2.h:122
bool isEnabled() const
Definition: C4Network2.h:203
bool isPastLobby() const
Definition: C4Network2.h:88

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init() [1/3]

C4Window * C4Console::Init ( C4AbstractApp app)
virtual

Definition at line 58 of file C4Console.cpp.

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

References C4ConsoleGUI::CreateConsoleWindow().

Referenced by C4Application::DoInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init() [2/3]

C4Window * C4Window::Init

Definition at line 322 of file C4AppT.cpp.

109 {return this;}

◆ Init() [3/3]

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

Definition at line 109 of file C4AppT.cpp.

109 {return this;}

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

Here is the caller graph for this function:

◆ InitGame()

void C4Console::InitGame ( )

Definition at line 590 of file C4Console.cpp.

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 }
const int NO_OWNER
Definition: C4Constants.h:137
C4ViewportList Viewports
bool UpdateViewportMenu()
Definition: C4Console.cpp:462
bool UpdatePlayerMenu()
Definition: C4Console.cpp:488
void UpdateInputCtrl()
Definition: C4Console.cpp:481
void SetCaptionToFilename(const char *szFilename)
Definition: C4Console.cpp:575
void Default()
Definition: C4Console.cpp:411
char ScenarioFilename[_MAX_PATH_LEN]
Definition: C4Game.h:102
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:71
int32_t GetStartupCount()
bool CreateViewport(int32_t player_nr, bool silent=false)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Message()

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

Definition at line 292 of file C4Console.cpp.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnObjectSelectionChanged()

void C4ConsoleGUI::OnObjectSelectionChanged ( class C4EditCursorSelection selection)
inlineinherited

Definition at line 112 of file C4ConsoleGUI.h.

112 { }

◆ OnStartGame()

void C4ConsoleGUI::OnStartGame ( )
inlineinherited

Definition at line 114 of file C4ConsoleGUI.h.

114 { }

Referenced by C4Application::GameTick().

Here is the caller graph for this function:

◆ Out()

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

Definition at line 684 of file C4Console.cpp.

684 {}

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

Here is the caller graph for this function:

◆ PerformUpdate()

void C4Window::PerformUpdate ( )
virtualinherited

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

Definition at line 85 of file C4App.cpp.

86 {
87 }

◆ PlayerJoin()

void C4Console::PlayerJoin ( )

Definition at line 513 of file C4Console.cpp.

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 }
C4PlayerList Players
void JoinNew(const char *szFilename)
void AppendBackslash()
Definition: StdBuf.cpp:248
void Copy()
Definition: StdBuf.h:467
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PropertyDlgClose()

void C4ConsoleGUI::PropertyDlgClose ( )
inherited

Definition at line 686 of file C4Console.cpp.

686 {}

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

Here is the caller graph for this function:

◆ PropertyDlgOpen()

bool C4ConsoleGUI::PropertyDlgOpen ( )
inherited

Definition at line 685 of file C4Console.cpp.

685 {return false;}

Referenced by C4EditCursor::OpenPropTools().

Here is the caller graph for this function:

◆ PropertyDlgUpdate()

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

Definition at line 687 of file C4Console.cpp.

687 {}

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

Here is the caller graph for this function:

◆ RecordingEnabled()

void C4ConsoleGUI::RecordingEnabled ( )
inherited

Definition at line 688 of file C4Console.cpp.

688 {}

Referenced by FileRecord().

Here is the caller graph for this function:

◆ RegisterRecentInput()

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

Definition at line 639 of file C4Console.cpp.

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 }
int32_t MaxScriptMRU
Definition: C4Config.h:87

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

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

Here is the caller graph for this function:

◆ ReInit()

bool C4Window::ReInit ( C4AbstractApp pApp)
virtualinherited

Definition at line 110 of file C4AppT.cpp.

110 {return false;}

◆ RemoveViewport()

void C4ConsoleGUI::RemoveViewport ( C4ViewportWindow cvp)
inlineinherited

Definition at line 111 of file C4ConsoleGUI.h.

111 { }

◆ RequestUpdate()

void C4Window::RequestUpdate ( )
virtualinherited

Definition at line 112 of file C4AppT.cpp.

112 {}

Referenced by C4FullScreen::Execute().

Here is the caller graph for this function:

◆ RestorePosition()

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

Definition at line 111 of file C4AppT.cpp.

111 {return false;}

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

Here is the caller graph for this function:

◆ SaveGame()

bool C4Console::SaveGame ( const char *  path)

Definition at line 127 of file C4Console.cpp.

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 }
void SetCursor(Cursor cursor)
Definition: C4Console.cpp:690
void Out(const char *message)
Definition: C4Console.cpp:684
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:292
bool Save(const char *szFilename)
Definition: C4GameSave.cpp:398
bool isHost() const
Definition: C4Network2.h:209

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

Referenced by FileSaveAs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveScenario()

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

Definition at line 151 of file C4Console.cpp.

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 }
C4Console Console
Definition: C4Globals.cpp:45
bool C4Group_PackDirectoryTo(const char *filename, const char *to_filename)
Definition: C4Group.cpp:292
bool C4Group_CopyItem(const char *source, const char *target, bool no_sorting, bool reset_attributes)
Definition: C4Group.cpp:115
C4Landscape Landscape
#define _MAX_PATH
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:204
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:833
bool ItemIdentical(const char *szFilename1, const char *szFilename2)
Definition: StdFile.cpp:879
char * GetFilename(char *szPath)
Definition: StdFile.cpp:42
bool FileExists(const char *szFileName)
StdStrBuf TempScenarioFile
Definition: C4Game.h:127
bool fScriptCreatedObjects
Definition: C4Game.h:118
bool IsPacked() const
Definition: C4Group.cpp:2541
C4Group * GetMother()
Definition: C4Group.cpp:2536
bool Close()
Definition: C4Group.cpp:971
bool Open(const char *group_name, bool do_create=false)
Definition: C4Group.cpp:660
LandscapeMode GetMode() const

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCaptionToFileName()

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

Definition at line 689 of file C4Console.cpp.

689 {}

Referenced by SetCaptionToFilename().

Here is the caller graph for this function:

◆ SetCaptionToFilename()

void C4Console::SetCaptionToFilename ( const char *  szFilename)

Definition at line 575 of file C4Console.cpp.

576 {
577  SetTitle(GetFilename(szFilename));
579 }
void SetCaptionToFileName(const char *file_name)
Definition: C4Console.cpp:689

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

Referenced by InitGame(), and SaveScenario().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCursor()

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

Definition at line 690 of file C4Console.cpp.

690 {}

Referenced by SaveGame(), and SaveScenario().

Here is the caller graph for this function:

◆ SetInputFunctions()

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

Definition at line 691 of file C4Console.cpp.

691 {}

Referenced by UpdateInputCtrl().

Here is the caller graph for this function:

◆ SetSize()

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

Definition at line 113 of file C4AppT.cpp.

113 {}

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

Here is the caller graph for this function:

◆ SetTitle()

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

Definition at line 114 of file C4AppT.cpp.

114 {}

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

Here is the caller graph for this function:

◆ ShowAboutWithCopyright()

void C4ConsoleGUI::ShowAboutWithCopyright ( StdStrBuf copyright)
inherited

Definition at line 692 of file C4Console.cpp.

692 {}

Referenced by HelpAbout().

Here is the caller graph for this function:

◆ StorePosition()

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

Definition at line 153 of file C4WindowSDL.cpp.

153 { return true; }

◆ TogglePause()

bool C4Console::TogglePause ( )

Definition at line 617 of file C4Console.cpp.

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

References Game, and C4Game::TogglePause().

Referenced by C4Game::InitKeyboard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToolsDlgClose()

void C4ConsoleGUI::ToolsDlgClose ( )
inherited

Definition at line 666 of file C4Console.cpp.

666 {}

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

Here is the caller graph for this function:

◆ ToolsDlgInitMaterialCtrls()

void C4ConsoleGUI::ToolsDlgInitMaterialCtrls ( class C4ToolsDlg dlg)
inherited

Definition at line 693 of file C4Console.cpp.

693 {}

Referenced by C4ToolsDlg::InitMaterialCtrls().

Here is the caller graph for this function:

◆ ToolsDlgOpen()

bool C4ConsoleGUI::ToolsDlgOpen ( class C4ToolsDlg dlg)
inherited

Definition at line 694 of file C4Console.cpp.

694 {return false;}

Referenced by C4ToolsDlg::Open().

Here is the caller graph for this function:

◆ ToolsDlgSelectBackMaterial()

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

Definition at line 697 of file C4Console.cpp.

697 {}

Referenced by C4ToolsDlg::SelectBackMaterial().

Here is the caller graph for this function:

◆ ToolsDlgSelectBackTexture()

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

Definition at line 698 of file C4Console.cpp.

698 {}

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

Here is the caller graph for this function:

◆ ToolsDlgSelectMaterial()

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

Definition at line 695 of file C4Console.cpp.

695 {}

Referenced by C4ToolsDlg::SelectMaterial().

Here is the caller graph for this function:

◆ ToolsDlgSelectTexture()

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

Definition at line 696 of file C4Console.cpp.

696 {}

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

Here is the caller graph for this function:

◆ UpdateHaltCtrls()

bool C4ConsoleGUI::UpdateHaltCtrls ( bool  fHalt)
inlineinherited

Definition at line 152 of file C4ConsoleGUI.h.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateInputCtrl()

void C4Console::UpdateInputCtrl ( )

Definition at line 481 of file C4Console.cpp.

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

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

Referenced by ConsoleDlgProc(), and InitGame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateMenus()

void C4Console::UpdateMenus ( )

Definition at line 504 of file C4Console.cpp.

505 {
506  if (!Active) return;
510  UpdateNetMenu();
511 }
void UpdateNetMenu()
Definition: C4Console.cpp:542

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateModeCtrls()

bool C4ConsoleGUI::UpdateModeCtrls ( int  iMode)
inherited

Definition at line 699 of file C4Console.cpp.

699 {return false;}

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

Here is the caller graph for this function:

◆ UpdateNetMenu()

void C4Console::UpdateNetMenu ( )

Definition at line 542 of file C4Console.cpp.

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 * getLocalName() const
Definition: C4Client.h:170
int32_t getLocalID() const
Definition: C4Client.h:171
void AddNetMenu()
Definition: C4Console.cpp:665
void AddNetMenuItemForPlayer(int32_t client_id, const char *text, C4ConsoleGUI::ClientOperation co)
Definition: C4Console.cpp:664
C4ClientList & Clients
Definition: C4Game.h:69
C4Network2Client * GetNextClient(C4Network2Client *pClient)
C4Network2ClientList Clients
Definition: C4Network2.h:116

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePlayerMenu()

bool C4Console::UpdatePlayerMenu ( )

Definition at line 488 of file C4Console.cpp.

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 }
void AddKickPlayerMenuItem(C4Player *player, StdStrBuf &player_text, bool enabled)
Definition: C4Console.cpp:662
C4Player * Next
Definition: C4Player.h:142
C4Player * First
Definition: C4PlayerList.h:31

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateStatusBars()

void C4Console::UpdateStatusBars ( )

Definition at line 105 of file C4Console.cpp.

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 }
void DisplayInfoText(InfoTextType type, StdStrBuf &text)
Definition: C4Console.cpp:679
int FPS
Definition: C4Console.h:93
int Time
Definition: C4Console.h:93
int32_t FrameCounter
Definition: C4Game.h:129
int32_t Time
Definition: C4Game.h:132
int32_t FPS
Definition: C4Game.h:111

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateViewportMenu()

bool C4Console::UpdateViewportMenu ( )

Definition at line 462 of file C4Console.cpp.

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 AddMenuItemForPlayer(C4Player *player, StdStrBuf &player_text)
Definition: C4Console.cpp:663

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

Referenced by InitGame(), and UpdateMenus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ViewportNew()

void C4Console::ViewportNew ( )

Definition at line 456 of file C4Console.cpp.

457 {
458  if (!fGameOpen) return;
460 }

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

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Active

◆ EditCursor

◆ Editing

◆ eKind

WindowKind C4Window::eKind
inherited

Definition at line 276 of file C4Window.h.

◆ fGameOpen

bool C4ConsoleGUI::fGameOpen
inherited

Definition at line 84 of file C4ConsoleGUI.h.

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

◆ FPS

int C4Console::FPS

Definition at line 93 of file C4Console.h.

Referenced by UpdateStatusBars().

◆ FrameCounter

int C4Console::FrameCounter

Definition at line 92 of file C4Console.h.

Referenced by C4Console(), and UpdateStatusBars().

◆ ObjectListDlg

C4ObjectListDlg C4Console::ObjectListDlg

Definition at line 89 of file C4Console.h.

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

◆ PropertyDlgObject

C4Object* C4ConsoleGUI::PropertyDlgObject
inherited

Definition at line 164 of file C4ConsoleGUI.h.

Referenced by Default().

◆ pSurface

◆ Time

int C4Console::Time

Definition at line 93 of file C4Console.h.

Referenced by UpdateStatusBars().

◆ ToolsDlg


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