forked from Mirrors/openclonk
Editor: Add most recently entered script lines to dropdown list.
This also enables easier auto-completion via arrow-down.shapetextures
parent
052e0358d9
commit
9e771acfd1
|
@ -84,6 +84,7 @@ void C4ConfigDeveloper::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(ExtraWarnings, "ExtraWarnings", 0 , false, true));
|
||||
pComp->Value(mkNamingAdapt(s(TodoFilename), "TodoFilename", "{SCENARIO}/TODO.txt", false, true));
|
||||
pComp->Value(mkNamingAdapt(s(AltTodoFilename), "AltTodoFilename2", "{USERPATH}/TODO.txt", false, true));
|
||||
pComp->Value(mkNamingAdapt(MaxScriptMRU, "MaxScriptMRU", 30 , false, false));
|
||||
}
|
||||
|
||||
void C4ConfigGraphics::CompileFunc(StdCompiler *pComp)
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
int32_t ExtraWarnings;
|
||||
char TodoFilename[CFG_MaxString + 1];
|
||||
char AltTodoFilename[CFG_MaxString + 1];
|
||||
int32_t MaxScriptMRU; // maximum number of remembered elements in recently used scripts
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
|
|
|
@ -395,9 +395,8 @@ void C4Console::ClearViewportMenu()
|
|||
|
||||
void C4Console::UpdateInputCtrl()
|
||||
{
|
||||
ClearInput();
|
||||
// add global and standard functions
|
||||
std::list <const char*> functions = ::ScriptEngine.GetFunctionNames(::GameScript.ScenPropList._getPropList());
|
||||
std::list <const char*> functions = ::Console.GetScriptSuggestions(::GameScript.ScenPropList._getPropList(), C4Console::MRU_Scenario);
|
||||
SetInputFunctions(functions);
|
||||
}
|
||||
|
||||
|
@ -529,6 +528,35 @@ bool C4Console::TogglePause()
|
|||
return Game.TogglePause();
|
||||
}
|
||||
|
||||
std::list<const char *> C4Console::GetScriptSuggestions(C4PropList *target, RecentScriptInputLists section) const
|
||||
{
|
||||
// Functions for this object
|
||||
std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(target);
|
||||
// Prepend most recently used script calls in reverse order
|
||||
const std::list<StdCopyStrBuf> &mru = recent_script_input[section];
|
||||
if (!mru.empty())
|
||||
{
|
||||
functions.insert(functions.begin(), NULL);
|
||||
// add pointers into string buffer list
|
||||
// do not iterate with for (auto i : mru) because this would copy the buffer and add stack pointers
|
||||
for (auto i = mru.begin(); i != mru.end(); ++i)
|
||||
functions.insert(functions.begin(), i->getData());
|
||||
}
|
||||
return functions;
|
||||
}
|
||||
|
||||
void C4Console::RegisterRecentInput(const char *input, RecentScriptInputLists section)
|
||||
{
|
||||
std::list<StdCopyStrBuf> &mru = recent_script_input[section];
|
||||
// remove previous copy (i.e.: Same input just gets pushed to top)
|
||||
mru.remove(StdCopyStrBuf(input));
|
||||
// register to list
|
||||
mru.push_back(StdCopyStrBuf(input));
|
||||
// limit history length
|
||||
if (static_cast<int32_t>(mru.size()) > ::Config.Developer.MaxScriptMRU)
|
||||
mru.erase(mru.begin());
|
||||
}
|
||||
|
||||
#if !(defined(USE_WIN32_WINDOWS) || defined(USE_COCOA) || defined(WITH_DEVELOPER_MODE))
|
||||
class C4ConsoleGUI::State: public C4ConsoleGUI::InternalState<class C4ConsoleGUI>
|
||||
{
|
||||
|
@ -559,7 +587,7 @@ bool C4ConsoleGUI::Message(char const*, bool) {return 0;}
|
|||
void C4ConsoleGUI::Out(char const*) {}
|
||||
bool C4ConsoleGUI::PropertyDlgOpen() {return 0;}
|
||||
void C4ConsoleGUI::PropertyDlgClose() {}
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection) {}
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &, bool) {}
|
||||
void C4ConsoleGUI::RecordingEnabled() {}
|
||||
void C4ConsoleGUI::SetCaptionToFileName(char const*) {}
|
||||
void C4ConsoleGUI::SetCursor(C4ConsoleGUI::Cursor) {}
|
||||
|
|
|
@ -89,6 +89,18 @@ public:
|
|||
|
||||
int FrameCounter;
|
||||
int Time,FPS;
|
||||
|
||||
// Script MRU: Keep track of recent script executions in global and local windows
|
||||
enum RecentScriptInputLists
|
||||
{
|
||||
MRU_Scenario = 0,
|
||||
MRU_Object = 1
|
||||
};
|
||||
private:
|
||||
std::list<StdCopyStrBuf> recent_script_input[2];
|
||||
public:
|
||||
std::list<const char *> GetScriptSuggestions(class C4PropList *target, RecentScriptInputLists section) const;
|
||||
void RegisterRecentInput(const char *input, RecentScriptInputLists section);
|
||||
};
|
||||
|
||||
extern C4Console Console;
|
||||
|
|
|
@ -171,7 +171,7 @@ void C4ConsoleGUI::PropertyDlgClose()
|
|||
[ctrler(this).objectsPanel orderOut:nil];
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection, bool force_function_update)
|
||||
{
|
||||
if (![ctrler(this).objectsPanel isVisible])
|
||||
return;
|
||||
|
|
|
@ -985,7 +985,7 @@ void C4ConsoleGUI::PropertyDlgClose()
|
|||
{
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection, bool force_function_update)
|
||||
{
|
||||
if (!state->propertydlg) return;
|
||||
if (!C4DevmodeDlg::GetWindow()) return;
|
||||
|
@ -993,7 +993,7 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
|||
GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(state->propertydlg_textview));
|
||||
gtk_text_buffer_set_text(buffer, rSelection.GetDataString().getData(), -1);
|
||||
|
||||
if (PropertyDlgObject == rSelection.GetObject()) return;
|
||||
if (PropertyDlgObject == rSelection.GetObject() && !force_function_update) return;
|
||||
PropertyDlgObject = rSelection.GetObject();
|
||||
|
||||
std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(PropertyDlgObject);
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
|
||||
bool PropertyDlgOpen();
|
||||
void PropertyDlgClose();
|
||||
void PropertyDlgUpdate(C4ObjectList &rSelection);
|
||||
void PropertyDlgUpdate(C4ObjectList &rSelection, bool force_function_update);
|
||||
C4Object * PropertyDlgObject;
|
||||
|
||||
bool ToolsDlgOpen(class C4ToolsDlg *dlg);
|
||||
|
|
|
@ -205,7 +205,12 @@ INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara
|
|||
wchar_t buffer[16000];
|
||||
GetDlgItemTextW(hDlg,IDC_COMBOINPUT,buffer,16000);
|
||||
if (buffer[0])
|
||||
Console.In(StdStrBuf(buffer).getData());
|
||||
{
|
||||
StdStrBuf in_char(buffer);
|
||||
::Console.RegisterRecentInput(in_char.getData(), C4Console::MRU_Scenario);
|
||||
::Console.In(in_char.getData());
|
||||
::Console.UpdateInputCtrl();
|
||||
}
|
||||
return true;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case IDC_BUTTONHALT:
|
||||
|
@ -863,7 +868,7 @@ static void SetComboItems(HWND hCombo, std::list<const char*> &items)
|
|||
}
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
||||
void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection, bool force_function_update)
|
||||
{
|
||||
HWND hDialog = state->hPropertyDlg;
|
||||
if (!hDialog) return;
|
||||
|
@ -872,10 +877,11 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
|||
SendDlgItemMessage(hDialog,IDC_EDITOUTPUT,EM_LINESCROLL,(WPARAM)0,(LPARAM)iLine);
|
||||
UpdateWindow(GetDlgItem(hDialog,IDC_EDITOUTPUT));
|
||||
|
||||
if (PropertyDlgObject == rSelection.GetObject()) return;
|
||||
if (PropertyDlgObject == rSelection.GetObject() && !force_function_update) return;
|
||||
PropertyDlgObject = rSelection.GetObject();
|
||||
|
||||
std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(PropertyDlgObject);
|
||||
std::list<const char *> functions = ::Console.GetScriptSuggestions(PropertyDlgObject, C4Console::MRU_Object);
|
||||
|
||||
HWND hCombo = GetDlgItem(state->hPropertyDlg, IDC_COMBOINPUT);
|
||||
wchar_t szLastText[500+1];
|
||||
// Remember old window text
|
||||
|
@ -891,7 +897,9 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
|||
|
||||
void C4ConsoleGUI::SetInputFunctions(std::list<const char*> &functions)
|
||||
{
|
||||
SetComboItems(GetDlgItem(hWindow,IDC_COMBOINPUT), functions);
|
||||
HWND hCombo = GetDlgItem(hWindow, IDC_COMBOINPUT);
|
||||
SendMessage(hCombo, CB_RESETCONTENT, 0, 0);
|
||||
SetComboItems(hCombo, functions);
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::ClearPlayerMenu()
|
||||
|
|
|
@ -75,7 +75,7 @@ void C4EditCursor::Execute()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
}
|
||||
if (!::Game.iTick35)
|
||||
Console.PropertyDlgUpdate(Selection);
|
||||
Console.PropertyDlgUpdate(Selection, false);
|
||||
}
|
||||
|
||||
bool C4EditCursor::Init()
|
||||
|
@ -204,7 +204,7 @@ void C4EditCursor::UpdateStatusBar()
|
|||
|
||||
void C4EditCursor::OnSelectionChanged()
|
||||
{
|
||||
Console.PropertyDlgUpdate(Selection);
|
||||
Console.PropertyDlgUpdate(Selection, false);
|
||||
Console.ObjectListDlg.Update(Selection);
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ bool C4EditCursor::OpenPropTools()
|
|||
{
|
||||
case C4CNS_ModeEdit: case C4CNS_ModePlay:
|
||||
Console.PropertyDlgOpen();
|
||||
Console.PropertyDlgUpdate(Selection);
|
||||
Console.PropertyDlgUpdate(Selection, false);
|
||||
break;
|
||||
case C4CNS_ModeDraw:
|
||||
Console.ToolsDlg.Open();
|
||||
|
@ -609,7 +609,9 @@ void C4EditCursor::FrameSelection()
|
|||
|
||||
bool C4EditCursor::In(const char *szText)
|
||||
{
|
||||
::Console.RegisterRecentInput(szText, C4Console::MRU_Object);
|
||||
EMMoveObject(EMMO_Script, Fix0, Fix0, NULL, &Selection, szText);
|
||||
::Console.PropertyDlgUpdate(Selection, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue