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 ()
 
virtual ~C4Console ()
 
void Default ()
 
virtual void Clear ()
 
virtual void Close ()
 
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
 
C4SurfacepSurface
 
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 71 of file C4ConsoleGUI.h.

enum C4ConsoleGUI::Cursor
inherited
Enumerator
CURSOR_Normal 
CURSOR_Wait 

Definition at line 65 of file C4ConsoleGUI.h.

Enumerator
CONSOLE_Cursor 
CONSOLE_FrameCounter 
CONSOLE_TimeFPS 

Definition at line 51 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 58 of file C4ConsoleGUI.h.

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

Definition at line 267 of file C4Window.h.

268  {
269  W_GuiWindow,
270  W_Console,
271  W_Viewport,
272  W_Fullscreen,
273  W_Control // wrapper to a render target control inside a window
274  };

Constructor & Destructor Documentation

C4Console::C4Console ( )

Definition at line 47 of file C4Console.cpp.

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

47  : C4ConsoleGUI()
48 {
49  Active = false;
50  Editing = true;
51  FrameCounter=0;
52  fGameOpen=false;
53 
54 #ifdef USE_WIN32_WINDOWS
55  hWindow=nullptr;
56 #endif
57 }
int FrameCounter
Definition: C4Console.h:92
bool Active
Definition: C4Window.h:278
C4Console::~C4Console ( )
virtual

Definition at line 59 of file C4Console.cpp.

60 {
61 }

Member Function Documentation

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

Definition at line 667 of file C4Console.cpp.

Referenced by UpdatePlayerMenu().

667 {}

Here is the caller graph for this function:

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

Definition at line 668 of file C4Console.cpp.

Referenced by UpdateViewportMenu().

668 {}

Here is the caller graph for this function:

void C4ConsoleGUI::AddNetMenu ( )
inherited

Definition at line 670 of file C4Console.cpp.

Referenced by UpdateNetMenu().

670 {}

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 669 of file C4Console.cpp.

Referenced by UpdateNetMenu().

669 {}

Here is the caller graph for this function:

void C4ConsoleGUI::AddViewport ( C4ViewportWindow cvp)
inlineinherited

Definition at line 111 of file C4ConsoleGUI.h.

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

Reimplemented in C4FullScreen.

Definition at line 286 of file C4Window.h.

286 { }
void C4Console::Clear ( )
virtual

Reimplemented from C4Window.

Definition at line 423 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().

424 {
425  if (pSurface) delete pSurface;
426  pSurface = 0;
427 
428  C4Window::Clear();
430 
431  EditCursor.Clear();
432  ToolsDlg.Clear();
435  ClearPlayerMenu();
436  ClearNetMenu();
437 #ifndef _WIN32
438  Application.Quit();
439 #endif
440 }
C4EditCursor EditCursor
Definition: C4Console.h:90
void ClearNetMenu()
Definition: C4Console.cpp:574
void ClearViewportMenu()
Definition: C4Console.cpp:480
void DeleteConsoleWindow()
Definition: C4Console.cpp:683
C4ToolsDlg ToolsDlg
Definition: C4Console.h:88
C4Surface * pSurface
Definition: C4Window.h:279
virtual void Quit()
virtual void Clear()
Definition: C4AppT.cpp:100
void ClearPlayerMenu()
Definition: C4Console.cpp:674
C4Application Application
Definition: C4Globals.cpp:44
void PropertyDlgClose()
Definition: C4Console.cpp:691

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ConsoleGUI::ClearLog ( )
inherited

Definition at line 672 of file C4Console.cpp.

Referenced by C4MessageInput::ProcessCommand().

672 {return 0;}

Here is the caller graph for this function:

void C4Console::ClearNetMenu ( )

Definition at line 574 of file C4Console.cpp.

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

Referenced by Clear(), and UpdateNetMenu().

575 {
576  if (!Active) return;
578 }
void ClearNetMenu()
Definition: C4Console.cpp:673
bool Active
Definition: C4Window.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::ClearPlayerMenu ( )
inherited

Definition at line 674 of file C4Console.cpp.

Referenced by Clear(), and UpdatePlayerMenu().

674 {}

Here is the caller graph for this function:

void C4Console::ClearPointers ( C4Object pObj)

Definition at line 410 of file C4Console.cpp.

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

Referenced by C4Game::ClearPointers().

411 {
414 }
C4EditCursor EditCursor
Definition: C4Console.h:90
void ClearPointers(C4Object *pObj)
void ClearPointers(class C4Object *obj)
Definition: C4ConsoleGUI.h:118

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::ClearViewportMenu ( )

Definition at line 480 of file C4Console.cpp.

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

Referenced by Clear(), and UpdateViewportMenu().

481 {
482  if (!Active) return;
484 }
void ClearViewportMenu()
Definition: C4Console.cpp:675
bool Active
Definition: C4Window.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::Close ( )
virtual

Implements C4Window.

Definition at line 442 of file C4Console.cpp.

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

Referenced by ConsoleDlgProc(), and FileQuit().

443 {
445  Application.Quit();
446 }
void CloseConsoleWindow()
Definition: C4ConsoleGUI.h:117
virtual void Quit()
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 117 of file C4ConsoleGUI.h.

Referenced by Close().

117 {}

Here is the caller graph for this function:

void C4Console::CloseGame ( )

Definition at line 614 of file C4Console.cpp.

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

Referenced by C4Game::Clear().

615 {
616  if (!Active || !fGameOpen) return;
617  fGameOpen=false;
619  SetTitle(LoadResStr("IDS_CNS_CONSOLE"));
620 }
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:144
void SetTitle(const char *Title)
Definition: C4AppT.cpp:112
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Active
Definition: C4Window.h:278

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 676 of file C4Console.cpp.

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

Referenced by Init().

677 {
678  C4Rect r(0, 0, 400, 350);
679  if (!C4Window::Init(C4Window::W_Console, pApp, LoadResStr("IDS_CNS_CONSOLE"), &r))
680  return false;
681  return true;
682 }
Definition: C4Rect.h:29
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:107

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 114 of file C4ConsoleGUI.h.

Referenced by FileNew().

114 { return false; }

Here is the caller graph for this function:

void C4Console::Default ( )

Definition at line 416 of file C4Console.cpp.

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

Referenced by InitGame().

417 {
419  PropertyDlgObject = 0;
420  ToolsDlg.Default();
421 }
C4EditCursor EditCursor
Definition: C4Console.h:90
C4ToolsDlg ToolsDlg
Definition: C4Console.h:88
C4Object * PropertyDlgObject
Definition: C4ConsoleGUI.h:165

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::DeleteConsoleWindow ( )
inherited

Definition at line 683 of file C4Console.cpp.

Referenced by Clear().

683 {}

Here is the caller graph for this function:

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

Definition at line 684 of file C4Console.cpp.

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

684 {}

Here is the caller graph for this function:

void C4ConsoleGUI::DoEnableControls ( bool  fEnable)
inherited

Definition at line 685 of file C4Console.cpp.

Referenced by C4ConsoleGUI::EnableControls().

685 {}

Here is the caller graph for this function:

void C4Console::DoHalt ( )

Definition at line 105 of file C4Console.cpp.

References Game, and C4Game::Pause().

Referenced by ConsoleDlgProc().

106 {
107  Game.Pause();
108 }
C4Game Game
Definition: C4Globals.cpp:52
bool Pause()
Definition: C4Game.cpp:954

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::DoPlay ( )

Definition at line 100 of file C4Console.cpp.

References Game, and C4Game::Unpause().

Referenced by ConsoleDlgProc().

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

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 686 of file C4Console.cpp.

Referenced by C4ConsoleGUI::UpdateHaltCtrls().

686 {return 0;}

Here is the caller graph for this function:

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

Definition at line 119 of file C4ConsoleGUI.h.

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

Definition at line 144 of file C4ConsoleGUI.h.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::EnsureDefinitionListInitialized ( )
inlineinherited

Definition at line 116 of file C4ConsoleGUI.h.

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

Definition at line 103 of file C4AppT.cpp.

Referenced by C4StartupOptionsDlg::C4StartupOptionsDlg().

103 {}

Here is the caller graph for this function:

void C4Console::Execute ( )

Definition at line 586 of file C4Console.cpp.

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

Referenced by C4Application::Draw().

587 {
593 }
C4EditCursor EditCursor
Definition: C4Console.h:90
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
void Execute()
Definition: C4ConsoleGUI.h:110
C4ObjectListDlg ObjectListDlg
Definition: C4Console.h:89
void UpdateStatusBars()
Definition: C4Console.cpp:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileClose ( )

Definition at line 387 of file C4Console.cpp.

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

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

388 {
389  if (!fGameOpen) return false;
391  return true;
392 }
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 303 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().

304 {
305  StdCopyStrBuf filename;
306 #ifdef WITH_QT_EDITOR
307  bool host_in_network = false;
308  if (!C4ConsoleGUI::CreateNewScenario(&filename, &host_in_network)) return false;
311  if (host_in_network)
312  {
313  Game.NetworkActive = true;
314  Game.fLobby = true;
315  }
316  Application.OpenGame(filename.getData());
317  return true;
318 #endif
319  // Not implemented
320  return false;
321 
322 }
const char * getData() const
Definition: StdBuf.h:450
C4Config Config
Definition: C4Config.cpp:837
C4Game Game
Definition: C4Globals.cpp:52
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:100
bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network)
Definition: C4ConsoleGUI.h:114
C4ConfigDeveloper Developer
Definition: C4Config.h:253
bool NetworkActive
Definition: C4Game.h:124
void ClearCommandLine()
bool fLobby
Definition: C4Game.h:120
C4Application Application
Definition: C4Globals.cpp:44
void OpenGame(const char *scenario=0)

Here is the call graph for this function:

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

Definition at line 324 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:.

325 {
326  // Get scenario file name
327  StdCopyStrBuf c4sfile("");
328  if (!filename)
329  {
330  if (!FileSelect(&c4sfile,
333  return false;
334  filename = c4sfile.getData();
335  }
338  if (host_in_network)
339  {
340  Game.NetworkActive = true;
341  Game.fLobby = true;
342  }
343  // Open game
344  Application.OpenGame(filename);
345  return true;
346 }
C4Config Config
Definition: C4Config.cpp:837
C4Game Game
Definition: C4Globals.cpp:52
#define FILE_SELECT_FILTER_FOR_C4S
Definition: C4Console.cpp:41
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:100
const DWORD OFN_FILEMUSTEXIST
Definition: C4ConsoleGUI.h:29
C4ConfigDeveloper Developer
Definition: C4Config.h:253
bool NetworkActive
Definition: C4Game.h:124
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:27
void ClearCommandLine()
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:394
bool fLobby
Definition: C4Game.h:120
C4Application Application
Definition: C4Globals.cpp:44
void OpenGame(const char *scenario=0)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileOpenWPlrs ( )

Definition at line 348 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:.

349 {
350  // Get scenario file name
351  StdCopyStrBuf c4sfile("");
352  if (!FileSelect(&c4sfile,
355  return false;
356  // Get player file name(s)
357  StdCopyStrBuf c4pfile("");
358  if (!FileSelect(&c4pfile,
359  "OpenClonk Player\0*.ocp\0\0",
361  )) return false;
362  // Compose command line
364  if (DirectoryExists(c4pfile.getData())) // Multiplayer
365  {
366  const char *cptr = c4pfile.getData() + SLen(c4pfile.getData()) + 1;
367  while (*cptr)
368  {
369  char c4pfile2[512 + 1] = "";
370  SAppend(c4pfile.getData(), c4pfile2, 512);
371  SAppend(DirSep, c4pfile2, 512);
372  SAppend(cptr, c4pfile2, 512);
373  SAddModule(Game.PlayerFilenames, c4pfile2);
374  cptr += SLen(cptr) + 1;
375  }
376  }
377  else // Single player
378  {
379  SAddModule(Game.PlayerFilenames, c4pfile.getData());
380  }
381  ::Config.Developer.AddRecentlyEditedScenario(c4sfile.getData());
382  // Open game
383  Application.OpenGame(c4sfile.getData());
384  return true;
385 }
const DWORD OFN_EXPLORER
Definition: C4ConsoleGUI.h:32
C4Config Config
Definition: C4Config.cpp:837
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:234
C4Game Game
Definition: C4Globals.cpp:52
size_t SLen(const char *sptr)
Definition: Standard.h:78
#define FILE_SELECT_FILTER_FOR_C4S
Definition: C4Console.cpp:41
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:100
const DWORD OFN_FILEMUSTEXIST
Definition: C4ConsoleGUI.h:29
C4ConfigDeveloper Developer
Definition: C4Config.h:253
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:27
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:694
char PlayerFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:106
void ClearCommandLine()
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:394
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:30
#define DirSep
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:534
C4Application Application
Definition: C4Globals.cpp:44
void OpenGame(const char *scenario=0)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileQuit ( )

Definition at line 448 of file C4Console.cpp.

References Close().

Referenced by ConsoleDlgProc().

449 {
450  Close();
451  return true;
452 }
virtual void Close()
Definition: C4Console.cpp:442

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileRecord ( )

Definition at line 399 of file C4Console.cpp.

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

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

400 {
401  // only in running mode
402  if (!Game.IsRunning || !::Control.IsRuntimeRecordPossible()) return false;
403  // start record!
405  // disable menuitem
407  return true;
408 }
bool IsRunning
Definition: C4Game.h:141
C4Game Game
Definition: C4Globals.cpp:52
C4GameControl Control
bool IsRuntimeRecordPossible() const
void RecordingEnabled()
Definition: C4Console.cpp:693
void RequestRuntimeRecord()

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::FileSave ( )

Definition at line 267 of file C4Console.cpp.

References SaveScenario().

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

268 {
269  // Save game
270  // FIXME: What about editing a savegame inplace? (Game.C4S.Head.SaveGame)
271  return SaveScenario(nullptr);
272 }
bool SaveScenario(const char *path, bool export_packed=false)
Definition: C4Console.cpp:156

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

275 {
276  // Do save-as dialog
277  StdCopyStrBuf filename("");
278  filename.Copy(Game.ScenarioFile.GetName());
279  if (export_packed)
280  {
281  RemoveExtension(&filename);
282  filename.Append("_packed.ocs");
283  }
284  if (!FileSelect(&filename,
285  "OpenClonk Scenario\0*.ocs\0\0",
287  true)) return false;
288  DefaultExtension(&filename,"ocs");
289  if (!export_packed) ::Config.Developer.AddRecentlyEditedScenario(filename.getData());
290  if (fSaveGame)
291  // Save game
292  return SaveGame(filename.getData());
293  else
294  return SaveScenario(filename.getData(), export_packed);
295 }
C4Config Config
Definition: C4Config.cpp:837
C4Game Game
Definition: C4Globals.cpp:52
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:100
const char * GetName() const
Definition: C4Group.cpp:1845
C4Group ScenarioFile
Definition: C4Game.h:88
C4ConfigDeveloper Developer
Definition: C4Config.h:253
void DefaultExtension(char *szFilename, const char *szExtension)
Definition: StdFile.cpp:284
void RemoveExtension(char *szFilename)
Definition: StdFile.cpp:316
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:27
bool SaveScenario(const char *path, bool export_packed=false)
Definition: C4Console.cpp:156
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:394
bool SaveGame(const char *path)
Definition: C4Console.cpp:132
const DWORD OFN_OVERWRITEPROMPT
Definition: C4ConsoleGUI.h:28

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 394 of file C4Console.cpp.

References C4ConsoleGUI::FileSelect().

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

395 {
396  return C4ConsoleGUI::FileSelect(sFilename, szFilter, dwFlags, fSave);
397 }
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave)
Definition: C4Console.cpp:687

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Window::FlashWindow ( )
inherited

Definition at line 75 of file C4AppMac.mm.

Referenced by C4AbstractApp::NotifyUserIfInactive().

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

Here is the caller graph for this function:

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

Definition at line 627 of file C4Console.cpp.

References C4AulScriptEngine::GetFunctionNames(), and ScriptEngine.

Referenced by UpdateInputCtrl().

628 {
629  // Functions for this object
630  std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(target);
631  // Prepend most recently used script calls in reverse order
632  const std::list<StdCopyStrBuf> &mru = recent_script_input[section];
633  if (!mru.empty())
634  {
635  functions.insert(functions.begin(), nullptr);
636  // add pointers into string buffer list
637  // do not iterate with for (auto i : mru) because this would copy the buffer and add stack pointers
638  for (auto i = mru.begin(); i != mru.end(); ++i)
639  functions.insert(functions.begin(), i->getData());
640  }
641  return functions;
642 }
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 106 of file C4AppT.cpp.

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

106 {return 0;}

Here is the caller graph for this function:

void C4Window::GrabMouse ( bool  grab)
inherited

Definition at line 105 of file C4AppT.cpp.

Referenced by C4Application::GameTick().

105 {}

Here is the caller graph for this function:

void C4Console::HelpAbout ( )

Definition at line 454 of file C4Console.cpp.

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

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

455 {
456  StdStrBuf strCopyright;
457  strCopyright.Format("Copyright (c) %s %s", C4COPYRIGHT_YEAR, C4COPYRIGHT_COMPANY);
458  ShowAboutWithCopyright(strCopyright);
459 }
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
void ShowAboutWithCopyright(StdStrBuf &copyright)
Definition: C4Console.cpp:697

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

71 {
72  if (!Active || !szText) return false;
73  // begins with '/'? then it's a command
74  if (*szText == '/')
75  {
77  // done
78  return true;
79  }
80  // begins with '#'? then it's a message. Route via ProcessInput to allow #/sound
81  // Also, in the lobby, everything written here is still a message
82  bool is_chat_command = (*szText == '#');
83  if (is_chat_command || (::Network.isEnabled() && !::Network.Status.isPastLobby()))
84  {
85  ::MessageInput.ProcessInput(szText + is_chat_command);
86  return true;
87  }
88  // editing enabled?
89  if (!EditCursor.EditingOK()) return false;
90  // pass through network queue
92  return true;
93 }
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:278
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 63 of file C4Console.cpp.

References C4ConsoleGUI::CreateConsoleWindow().

Referenced by C4Application::DoInit().

64 {
66  return nullptr;
67  return this;
68 }
bool CreateConsoleWindow(C4AbstractApp *application)
Definition: C4Console.cpp:676

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 107 of file C4AppT.cpp.

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

107 {return this;}

Here is the caller graph for this function:

void C4Console::InitGame ( )

Definition at line 595 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().

596 {
597  if (!Active) return;
598  // Default game dependent members
599  Default();
601  // Init game dependent members
602  EditCursor.Init();
603 
604  // Console updates
605  fGameOpen=true;
606  UpdateInputCtrl();
610  // Initial neutral viewport unless started with players
612 }
C4EditCursor EditCursor
Definition: C4Console.h:90
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:144
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:104
C4Game Game
Definition: C4Globals.cpp:52
void UpdateInputCtrl()
Definition: C4Console.cpp:486
void SetCaptionToFilename(const char *szFilename)
Definition: C4Console.cpp:580
const int NO_OWNER
Definition: C4Constants.h:138
bool CreateViewport(int32_t iPlayer, bool fSilent=false)
Definition: C4Viewport.cpp:920
int32_t GetStartupCount()
void Default()
Definition: C4Console.cpp:416
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
bool UpdatePlayerMenu()
Definition: C4Console.cpp:493
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
bool Active
Definition: C4Window.h:278
bool UpdateViewportMenu()
Definition: C4Console.cpp:467

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

298 {
299  if (!Active) return false;
300  return C4ConsoleGUI::Message(szMessage, fQuery);
301 }
bool Message(const char *message, bool query)
Definition: C4Console.cpp:688
bool Active
Definition: C4Window.h:278

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 113 of file C4ConsoleGUI.h.

113 { }
void C4ConsoleGUI::OnStartGame ( )
inlineinherited

Definition at line 115 of file C4ConsoleGUI.h.

Referenced by C4Application::GameTick().

115 { }

Here is the caller graph for this function:

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

Definition at line 689 of file C4Console.cpp.

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

689 {}

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 518 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:.

519 {
520  // Get player file name(s)
521  StdCopyStrBuf c4pfile("");
522  if (!FileSelect(&c4pfile,
523  "OpenClonk Player\0*.ocp\0\0",
525  )) return;
526 
527  // Multiple players
528  if (DirectoryExists(c4pfile.getData()))
529  {
530  const char *cptr = c4pfile.getData() + SLen(c4pfile.getData()) + 1;
531  while (*cptr)
532  {
533  StdStrBuf f;
534  f.Copy(c4pfile.getData());
535  f.AppendBackslash(); f.Append(cptr);
536  cptr += SLen(cptr)+1;
538  }
539  }
540  // Single player
541  else
542  {
543  ::Players.JoinNew(c4pfile.getData());
544  }
545 }
const char * getData() const
Definition: StdBuf.h:450
const DWORD OFN_EXPLORER
Definition: C4ConsoleGUI.h:32
size_t SLen(const char *sptr)
Definition: Standard.h:78
void AppendBackslash()
Definition: StdBuf.cpp:255
void JoinNew(const char *szFilename)
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
C4PlayerList Players
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:27
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:694
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false)
Definition: C4Console.cpp:394
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:30
void Copy()
Definition: StdBuf.h:475

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::PropertyDlgClose ( )
inherited

Definition at line 691 of file C4Console.cpp.

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

691 {}

Here is the caller graph for this function:

bool C4ConsoleGUI::PropertyDlgOpen ( )
inherited

Definition at line 690 of file C4Console.cpp.

Referenced by C4EditCursor::OpenPropTools().

690 {return 0;}

Here is the caller graph for this function:

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

Definition at line 692 of file C4Console.cpp.

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

692 {}

Here is the caller graph for this function:

void C4ConsoleGUI::RecordingEnabled ( )
inherited

Definition at line 693 of file C4Console.cpp.

Referenced by FileRecord().

693 {}

Here is the caller graph for this function:

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

Definition at line 644 of file C4Console.cpp.

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

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

645 {
646  std::list<StdCopyStrBuf> &mru = recent_script_input[section];
647  // remove previous copy (i.e.: Same input just gets pushed to top)
648  mru.remove(StdCopyStrBuf(input));
649  // register to list
650  mru.push_back(StdCopyStrBuf(input));
651  // limit history length
652  if (static_cast<int32_t>(mru.size()) > ::Config.Developer.MaxScriptMRU)
653  mru.erase(mru.begin());
654 }
C4Config Config
Definition: C4Config.cpp:837
int32_t MaxScriptMRU
Definition: C4Config.h:87
C4ConfigDeveloper Developer
Definition: C4Config.h:253

Here is the caller graph for this function:

bool C4Window::ReInit ( C4AbstractApp pApp)
virtualinherited

Definition at line 108 of file C4AppT.cpp.

108 {return 0;}
void C4ConsoleGUI::RemoveViewport ( C4ViewportWindow cvp)
inlineinherited

Definition at line 112 of file C4ConsoleGUI.h.

112 { }
void C4Window::RequestUpdate ( )
virtualinherited

Definition at line 110 of file C4AppT.cpp.

Referenced by C4FullScreen::Execute().

110 {}

Here is the caller graph for this function:

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

Definition at line 109 of file C4AppT.cpp.

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

109 {return 0;}

Here is the caller graph for this function:

bool C4Console::SaveGame ( const char *  path)

Definition at line 132 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().

133 {
134  // Network hosts only
135  if (::Network.isEnabled() && !::Network.isHost())
136  { Message(LoadResStr("IDS_GAME_NOCLIENTSAVE")); return false; }
137 
138  // Save game to open scenario file
139  bool fOkay=true;
141 
142  C4GameSave *pGameSave = new C4GameSaveSavegame();
143  if (!pGameSave->Save(path))
144  { Out("Save failed"); fOkay=false; }
145  delete pGameSave;
146 
148 
149  // Status report
150  if (!fOkay) Message(LoadResStr("IDS_CNS_SAVERROR"));
151  else Out(LoadResStr("IDS_CNS_GAMESAVED"));
152 
153  return fOkay;
154 }
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:400
void Out(const char *message)
Definition: C4Console.cpp:689
bool isEnabled() const
Definition: C4Network2.h:203
void SetCursor(Cursor cursor)
Definition: C4Console.cpp:695
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:297

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

157 {
158  C4Group *save_target_group = &Game.ScenarioFile;
159  C4Group export_group;
160  if (export_packed)
161  {
162  // Export to packed file: Delete existing
163  if (FileExists(path))
164  {
165  if (ItemIdentical(Game.ScenarioFilename, path) || !EraseItem(path))
166  {
167  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), path).getData());
168  return false;
169  }
170  }
171  // Write into new, packed copy
172  if (!C4Group_PackDirectoryTo(Game.ScenarioFilename, path) || !export_group.Open(path))
173  {
174  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), path).getData());
175  return false;
176  }
177  save_target_group = &export_group;
178  }
179  else if (path)
180  {
181  // When trying to save into a subfolder of the existing scenario, the copy function
182  // below will try to recursively copy everything until it blows the stack. There is
183  // really no good reason to do this, so we just disallow it here.
184  if (SEqual2(path, Game.ScenarioFilename))
185  {
186  Message(LoadResStr("IDS_CNS_RECURSIVESAVEASERROR"));
187  return false;
188  }
189  // Open new scenario file
190  // Close current scenario file to allow re-opening at new path
192  // Copy current scenario file to target
194  {
195  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"),path).getData());
196  return false;
197  }
198  // Re-open at new path (unless exporting, in which case the export is just a copy)
202  {
203  Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), Game.ScenarioFilename).getData());
204  return false;
205  }
206  }
207  else
208  {
209  // Do not save to temp network file
211  {
212  Message(LoadResStr("IDS_CNS_NONETREFSAVE"));
213  return false;
214  }
215  }
216 
217  // Can't save to child groups
218  if (save_target_group->GetMother() && save_target_group->GetMother()->IsPacked())
219  {
220  StdStrBuf str;
221  str.Format(LoadResStr("IDS_CNS_NOCHILDSAVE"),
222  GetFilename(save_target_group->GetName()));
223  Message(str.getData());
224  return false;
225  }
226 
227  // Save game to open scenario file
229 
230  bool fOkay=true;
232  if (!pGameSave->Save(*save_target_group, false))
233  { Out("Game::Save failed"); fOkay=false; }
234  delete pGameSave;
235 
236  // Close and reopen scenario file to fix file changes
237  if (!export_packed)
238  {
239  if (!Game.ScenarioFile.Close())
240  {
241  Out("ScenarioFile::Close failed"); fOkay = false;
242  }
244  {
245  Out("ScenarioFile::Open failed"); fOkay = false;
246  }
247  }
248 
250 
251  // Initialize/script notification
253  {
254  StdStrBuf str(LoadResStr("IDS_CNS_SCRIPTCREATEDOBJECTS"));
255  str += LoadResStr("IDS_CNS_WARNDOUBLE");
256  Message(str.getData());
257  Game.fScriptCreatedObjects = false;
258  }
259 
260  // Status report
261  if (!fOkay) Message(LoadResStr("IDS_CNS_SAVERROR"));
262  else Out(LoadResStr("IDS_CNS_SCENARIOSAVED"));
263 
264  return fOkay;
265 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:55
const char * getData() const
Definition: StdBuf.h:450
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:104
StdStrBuf TempScenarioFile
Definition: C4Game.h:128
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
C4Console Console
Definition: C4Globals.cpp:45
C4Group * GetMother()
Definition: C4Group.cpp:2004
bool ItemIdentical(const char *szFilename1, const char *szFilename2)
Definition: StdFile.cpp:865
C4Game Game
Definition: C4Globals.cpp:52
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
#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:400
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:580
C4Group ScenarioFile
Definition: C4Game.h:88
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:689
bool Close()
Definition: C4Group.cpp:755
LandscapeMode GetMode() const
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:819
bool FileExists(const char *szFilename)
Definition: StdFile.cpp:439
bool Active
Definition: C4Window.h:278
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:175
bool IsPacked() const
Definition: C4Group.cpp:2009
bool fScriptCreatedObjects
Definition: C4Game.h:119
void SetCursor(Cursor cursor)
Definition: C4Console.cpp:695
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:297
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

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 580 of file C4Console.cpp.

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

Referenced by InitGame(), and SaveScenario().

581 {
582  SetTitle(GetFilename(szFilename));
584 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:55
void SetCaptionToFileName(const char *file_name)
Definition: C4Console.cpp:694
void SetTitle(const char *Title)
Definition: C4AppT.cpp:112

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 694 of file C4Console.cpp.

Referenced by SetCaptionToFilename().

694 {}

Here is the caller graph for this function:

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

Definition at line 695 of file C4Console.cpp.

Referenced by SaveGame(), and SaveScenario().

695 {}

Here is the caller graph for this function:

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

Definition at line 696 of file C4Console.cpp.

Referenced by UpdateInputCtrl().

696 {}

Here is the caller graph for this function:

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

Definition at line 111 of file C4AppT.cpp.

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

111 {}

Here is the caller graph for this function:

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

Definition at line 112 of file C4AppT.cpp.

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

112 {}

Here is the caller graph for this function:

void C4ConsoleGUI::ShowAboutWithCopyright ( StdStrBuf copyright)
inherited

Definition at line 697 of file C4Console.cpp.

Referenced by HelpAbout().

697 {}

Here is the caller graph for this function:

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

Definition at line 143 of file C4WindowSDL.cpp.

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

Definition at line 622 of file C4Console.cpp.

References Game, and C4Game::TogglePause().

Referenced by C4Game::InitKeyboard().

623 {
624  return Game.TogglePause();
625 }
C4Game Game
Definition: C4Globals.cpp:52
bool TogglePause()
Definition: C4Game.cpp:946

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgClose ( )
inherited

Definition at line 671 of file C4Console.cpp.

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

671 {}

Here is the caller graph for this function:

void C4ConsoleGUI::ToolsDlgInitMaterialCtrls ( class C4ToolsDlg dlg)
inherited

Definition at line 698 of file C4Console.cpp.

Referenced by C4ToolsDlg::InitMaterialCtrls().

698 {}

Here is the caller graph for this function:

bool C4ConsoleGUI::ToolsDlgOpen ( class C4ToolsDlg dlg)
inherited

Definition at line 699 of file C4Console.cpp.

Referenced by C4ToolsDlg::Open().

699 {return 0;}

Here is the caller graph for this function:

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

Definition at line 702 of file C4Console.cpp.

Referenced by C4ToolsDlg::SelectBackMaterial().

702 {}

Here is the caller graph for this function:

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

Definition at line 703 of file C4Console.cpp.

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

703 {}

Here is the caller graph for this function:

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

Definition at line 700 of file C4Console.cpp.

Referenced by C4ToolsDlg::SelectMaterial().

700 {}

Here is the caller graph for this function:

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

Definition at line 701 of file C4Console.cpp.

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

701 {}

Here is the caller graph for this function:

bool C4ConsoleGUI::UpdateHaltCtrls ( bool  fHalt)
inlineinherited

Definition at line 153 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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::UpdateInputCtrl ( )

Definition at line 486 of file C4Console.cpp.

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

Referenced by ConsoleDlgProc(), and InitGame().

487 {
488  // add global and standard functions
490  SetInputFunctions(functions);
491 }
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:627
void SetInputFunctions(std::list< const char * > &functions)
Definition: C4Console.cpp:696
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 509 of file C4Console.cpp.

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

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

510 {
511  if (!Active) return;
515  UpdateNetMenu();
516 }
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:144
void UpdateNetMenu()
Definition: C4Console.cpp:547
bool UpdatePlayerMenu()
Definition: C4Console.cpp:493
bool Active
Definition: C4Window.h:278
bool UpdateViewportMenu()
Definition: C4Console.cpp:467

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 704 of file C4Console.cpp.

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

704 {return 0;}

Here is the caller graph for this function:

void C4Console::UpdateNetMenu ( )

Definition at line 547 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().

548 {
549  // Active & network hosting check
550  if (!Active) return;
551  if (!::Network.isHost() || !::Network.isEnabled()) return;
552  // Clear old
553  ClearNetMenu();
554  // Insert menu
556 
557  // Host
558  StdStrBuf str;
559  str.Format(LoadResStr("IDS_MNU_NETHOST"),Game.Clients.getLocalName(),Game.Clients.getLocalID());
561  // Clients
562  for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
563  {
564  if (pClient->isHost()) continue;
565  str.Format(LoadResStr(pClient->isActivated() ? "IDS_MNU_NETCLIENT_DEACTIVATE" : "IDS_MNU_NETCLIENT_ACTIVATE"),
566  pClient->getName(), pClient->getID());
567  AddNetMenuItemForPlayer(pClient->getID(), str.getData(), pClient->isActivated() ? C4ConsoleGUI::CO_Deactivate : C4ConsoleGUI::CO_Activate);
568  str.Format(LoadResStr("IDS_NET_KICKCLIENTEX"), pClient->getName(), pClient->getID());
569  AddNetMenuItemForPlayer(pClient->getID(), str.getData(), C4ConsoleGUI::CO_Kick);
570  }
571  return;
572 }
const char * getData() const
Definition: StdBuf.h:450
bool isHost() const
Definition: C4Network2.h:209
C4Network2Client * GetNextClient(C4Network2Client *pClient)
void ClearNetMenu()
Definition: C4Console.cpp:574
C4Game Game
Definition: C4Globals.cpp:52
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
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:669
C4Network2ClientList Clients
Definition: C4Network2.h:116
bool Active
Definition: C4Window.h:278
C4ClientList & Clients
Definition: C4Game.h:71
void AddNetMenu()
Definition: C4Console.cpp:670

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::UpdatePlayerMenu ( )

Definition at line 493 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().

494 {
495  if (!Active) return false;
496  ClearPlayerMenu();
497  for (C4Player *pPlr=::Players.First; pPlr; pPlr=pPlr->Next)
498  {
499  StdStrBuf sText;
500  if (::Network.isEnabled())
501  sText.Format(LoadResStr("IDS_CNS_PLRQUITNET"),pPlr->GetName(),pPlr->AtClientName);
502  else
503  sText.Format(LoadResStr("IDS_CNS_PLRQUIT"),pPlr->GetName());
504  AddKickPlayerMenuItem(pPlr, sText, (!::Network.isEnabled() || ::Network.isHost()) && Editing);
505  }
506  return true;
507 }
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:181
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:667
bool Active
Definition: C4Window.h:278
C4Player * Next
Definition: C4Player.h:144
void ClearPlayerMenu()
Definition: C4Console.cpp:674

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::UpdateStatusBars ( )

Definition at line 110 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().

111 {
112  if (!Active) return;
113  // Frame counter
115  {
117  StdStrBuf str;
118  str.Format("Frame: %i",FrameCounter);
120  }
121  // Time & FPS
122  if ((Game.Time!=Time) || (Game.FPS!=FPS))
123  {
124  Time=Game.Time;
125  FPS=Game.FPS;
126  StdStrBuf str;
127  str.Format("%02d:%02d:%02d (%i FPS)",Time/3600,(Time%3600)/60,Time%60,FPS);
129  }
130 }
int FrameCounter
Definition: C4Console.h:92
C4Game Game
Definition: C4Globals.cpp:52
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
int Time
Definition: C4Console.h:93
int32_t FrameCounter
Definition: C4Game.h:130
int32_t FPS
Definition: C4Game.h:113
int32_t Time
Definition: C4Game.h:133
int FPS
Definition: C4Console.h:93
bool Active
Definition: C4Window.h:278
void DisplayInfoText(InfoTextType type, StdStrBuf &text)
Definition: C4Console.cpp:684

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Console::UpdateViewportMenu ( )

Definition at line 467 of file C4Console.cpp.

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

Referenced by InitGame(), and UpdateMenus().

468 {
469  if (!Active) return false;
471  for (C4Player *pPlr=::Players.First; pPlr; pPlr=pPlr->Next)
472  {
473  StdStrBuf sText;
474  sText.Format(LoadResStr("IDS_CNS_NEWPLRVIEWPORT"),pPlr->GetName());
476  }
477  return true;
478 }
void ClearViewportMenu()
Definition: C4Console.cpp:480
C4Player * First
Definition: C4PlayerList.h:31
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4PlayerList Players
bool Active
Definition: C4Window.h:278
C4Player * Next
Definition: C4Player.h:144
void AddMenuItemForPlayer(C4Player *player, StdStrBuf &player_text)
Definition: C4Console.cpp:668

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Console::ViewportNew ( )

Definition at line 461 of file C4Console.cpp.

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

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

462 {
463  if (!fGameOpen) return;
465 }
const int NO_OWNER
Definition: C4Constants.h:138
bool CreateViewport(int32_t iPlayer, bool fSilent=false)
Definition: C4Viewport.cpp:920
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 280 of file C4Window.h.

bool C4ConsoleGUI::fGameOpen
inherited

Definition at line 85 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 165 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: