forked from Mirrors/openclonk
Add /todo message board command.
Adds text to local TODO.txt file. Useful for taking notes quickly e.g. when testing new scenarios in a network game. TODO filenames are configurable. Default file is TODO.txt in the scenario file (if it's unpacked) and TODO.txt on the current path if access to the first location failed.stable-6.1
parent
179498984d
commit
90cca08d63
|
@ -383,6 +383,7 @@ IDS_ERR_SAVE_TARGETGRP=Spiel speichern: Zielgruppe kann nicht als %s erzeugt wer
|
|||
IDS_ERR_SCENSECTION=Fehler beim Laden des Szenarienteils "%s"
|
||||
IDS_ERR_SWITCHRES=Fehler beim Ändern der Bildschirmauflösung: %s
|
||||
IDS_ERR_TITLE=Fehler
|
||||
IDS_ERR_TODO=Fehler beim Schreiben in TODO-Datei.
|
||||
IDS_ERR_UNKNOWNCMD=Unbekannter Befehl: "%s" - Befehl /help für eine Liste gültiger Befehle
|
||||
IDS_ERR_HELPCMD=Grundlegende Befehle im IRC-Chat:|/join [Chatraum] - Neuen Chatraum betreten|/part - Diesen Chatraum verlassen|/notice [Benutzer] [Nachricht] - Sende eine Nachricht an den Benutzer|/query [Benutzer] - Öffne ein neues Chatfenster für einen privaten Dialog mit dem Benutzer|/msg [Benutzer] [Nachricht] - Dasselbe wie /query, nur dass bereits die erste Nachrich geschickt wird|/nick [Neuer Spitzname] - Wähle einen neuen Spitznamen|/quit - Chat ganz verlassen|/raw - Raw-Kommando senden
|
||||
IDS_ERR_UNSUPPORTED_ACCELERATOR=Die Schnelltaste "%s" wird nicht unterstützt. (Im Text "%s".) Bitte melde diesen Fehler.
|
||||
|
@ -872,6 +873,7 @@ IDS_PRC_UNREGUSER=Nicht registrierter Nutzer
|
|||
IDS_PRC_UPDATEFONT=Schrift %s(%d,%d) wird aktualisiert...
|
||||
IDS_SELECT_CREW=Mannschaft
|
||||
IDS_TEXT_ABORTSTARTCOUNTDOWN=Rundenstart abbrechen.
|
||||
IDS_TEXT_ADDTODO=Text zur lokalen TODO-Liste hinzufügen.
|
||||
IDS_TEXT_ALERTTHEHOSTIFTHEHOSTISAW=Den Host aufwecken (wenn er nicht da ist).
|
||||
IDS_TEXT_CHANGETHECOLOROFTHESPECIF=Farbe des angegebenen Spielers ändern.
|
||||
IDS_TEXT_CHANGEYOUROWNPLAYERCOLOR=Eigene Farbe ändern.
|
||||
|
|
|
@ -383,6 +383,7 @@ IDS_ERR_SAVE_TARGETGRP=SaveGame: Unable to create target group at %s.
|
|||
IDS_ERR_SCENSECTION=Error loading scenario section "%s"
|
||||
IDS_ERR_SWITCHRES=Error switching resolution: %s
|
||||
IDS_ERR_TITLE=Error
|
||||
IDS_ERR_TODO=Error writing to TODO file.
|
||||
IDS_ERR_UNKNOWNCMD=Unknown command: "%s" - type /help to get a list of valid commands
|
||||
IDS_ERR_HELPCMD=Basic commands in the IRC-chat:|/join [channel] - Enter a new chat room|/part - Leave this chat room|/notice [user] [message] - Send a message to the user|/query [user] - Open a new chat window to chat for chatting with the user|/msg [user] [message] - The same as /query, only that the first message is already sent|/nick [new nick name] - Choose a new nick name|/quit - Exit the chat|/raw - Send a raw command
|
||||
IDS_ERR_UNSUPPORTED_ACCELERATOR=Accelerator key "%s" not supported. (In string "%s"). Please report this error.
|
||||
|
@ -872,6 +873,7 @@ IDS_PRC_UNREGUSER=Unregistered user
|
|||
IDS_PRC_UPDATEFONT=Updating font %s(%d,%d)...
|
||||
IDS_SELECT_CREW=Crew
|
||||
IDS_TEXT_ABORTSTARTCOUNTDOWN=Abort start countdown.
|
||||
IDS_TEXT_ADDTODO=Add text to local TODO list.
|
||||
IDS_TEXT_ALERTTHEHOSTIFTHEHOSTISAW=Alert the host (if the host is away).
|
||||
IDS_TEXT_CHANGETHECOLOROFTHESPECIF=Change the color of the specified player.
|
||||
IDS_TEXT_CHANGEYOUROWNPLAYERCOLOR=Change your own player color.
|
||||
|
|
|
@ -133,7 +133,7 @@ bool CStdFile::Open(const char *szFilename, bool fCompressed)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CStdFile::Append(const char *szFilename)
|
||||
bool CStdFile::Append(const char *szFilename, bool text)
|
||||
{
|
||||
SCopy(szFilename,Name,_MAX_PATH);
|
||||
thread_check.Set();
|
||||
|
@ -141,9 +141,9 @@ bool CStdFile::Append(const char *szFilename)
|
|||
ModeWrite=true;
|
||||
// Open standard file
|
||||
#ifdef _WIN32
|
||||
if (!(hFile=_wfopen(GetWideChar(Name),L"ab"))) return false;
|
||||
if (!(hFile = _wfopen(GetWideChar(Name), text ? L"at" : L"ab"))) return false;
|
||||
#else
|
||||
if (!(hFile=fopen(Name,"ab"))) return false;
|
||||
if (!(hFile=fopen(Name,text ? "at" : "ab"))) return false;
|
||||
#endif
|
||||
// Reset buffer
|
||||
ClearBuffer();
|
||||
|
@ -268,7 +268,7 @@ bool CStdFile::Write(const void *pBuffer, int iSize)
|
|||
bool CStdFile::WriteString(const char *szStr)
|
||||
{
|
||||
thread_check.Check();
|
||||
BYTE nl[2]={0x0D,0x0A};
|
||||
BYTE nl[2]={0x0D,0x0A};
|
||||
if (!szStr) return false;
|
||||
int size=SLen(szStr);
|
||||
if (!Write((void*)szStr,size)) return false;
|
||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
|||
public:
|
||||
bool Create(const char *szFileName, bool fCompressed=false, bool fExecutable=false, bool fMemory=false);
|
||||
bool Open(const char *szFileName, bool fCompressed=false);
|
||||
bool Append(const char *szFilename); // append (uncompressed only)
|
||||
bool Append(const char *szFilename, bool text=false); // append (uncompressed only)
|
||||
bool Close(StdBuf **ppMemory = NULL);
|
||||
bool Default();
|
||||
bool Read(void *pBuffer, size_t iSize) { return Read(pBuffer, iSize, 0); }
|
||||
|
|
|
@ -80,8 +80,10 @@ void C4ConfigGeneral::CompileFunc(StdCompiler *pComp)
|
|||
|
||||
void C4ConfigDeveloper::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(AutoFileReload, "AutoFileReload", 1 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(ExtraWarnings, "ExtraWarnings", 0 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(AutoFileReload, "AutoFileReload", 1 , false, true));
|
||||
pComp->Value(mkNamingAdapt(ExtraWarnings, "ExtraWarnings", 0 , false, true));
|
||||
pComp->Value(mkNamingAdapt(s(TodoFilename), "TodoFilename", "{SCENARIO}/TODO.txt", false, true));
|
||||
pComp->Value(mkNamingAdapt(s(AltTodoFilename), "AltTodoFilename", "TODO.txt" , false, true));
|
||||
}
|
||||
|
||||
void C4ConfigGraphics::CompileFunc(StdCompiler *pComp)
|
||||
|
|
|
@ -83,6 +83,8 @@ class C4ConfigDeveloper
|
|||
public:
|
||||
int32_t AutoFileReload;
|
||||
int32_t ExtraWarnings;
|
||||
char TodoFilename[CFG_MaxString + 1];
|
||||
char AltTodoFilename[CFG_MaxString + 1];
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
|
|
|
@ -583,6 +583,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
LogF("/set comment [comment] - %s", LoadResStr("IDS_TEXT_SETANEWNETWORKCOMMENT"));
|
||||
LogF("/set password [password] - %s", LoadResStr("IDS_TEXT_SETANEWNETWORKPASSWORD"));
|
||||
LogF("/set maxplayer [number] - %s", LoadResStr("IDS_TEXT_SETANEWMAXIMUMNUMBEROFPLA"));
|
||||
LogF("/todo [text] - %s", LoadResStr("IDS_TEXT_ADDTODO"));
|
||||
LogF("/clear - %s", LoadResStr("IDS_MSG_CLEARTHEMESSAGEBOARD"));
|
||||
return true;
|
||||
}
|
||||
|
@ -772,6 +773,32 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
return true;
|
||||
}
|
||||
|
||||
// add to TODO list
|
||||
if (SEqual(szCmdName, "todo"))
|
||||
{
|
||||
// must add something
|
||||
if (!pCmdPar || !*pCmdPar) return false;
|
||||
// try writing main file (usually {SCENARIO}/TODO.txt); if access is not possible, e.g. because scenario is packed, write to alternate file
|
||||
const char *todo_filenames[] = { ::Config.Developer.TodoFilename, ::Config.Developer.AltTodoFilename };
|
||||
bool success = false;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
StdCopyStrBuf todo_filename(todo_filenames[i]);
|
||||
int replacements = todo_filename.Replace("{SCENARIO}", Game.ScenarioFile.GetFullName().getData());
|
||||
// sanity check if entered in editor with no file open
|
||||
if (replacements && !Game.ScenarioFile.IsOpen()) continue;
|
||||
// try to append. May fail e.g. on packed scenario file, name getting too long, etc. Then fallback to alternate location.
|
||||
CStdFile todo_file;
|
||||
if (!todo_file.Append(todo_filename.getData())) continue;
|
||||
if (!todo_file.WriteString(pCmdPar)) continue;
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
// no message on success to avoid cluttering the chat during debug sessions
|
||||
if (!success) Log(LoadResStr("IDS_ERR_TODO"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// custom command
|
||||
C4MessageBoardCommand *pCmd;
|
||||
if (Game.IsRunning)
|
||||
|
|
Loading…
Reference in New Issue