Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 1f25177

Browse files
fix core extension
1 parent 43c0cf5 commit 1f25177

6 files changed

Lines changed: 33 additions & 32 deletions

File tree

OFS-lib/UI/KeybindingSystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ bool KeybindingSystem::PassiveModifier(const char* name) noexcept
662662
return false;
663663
}
664664

665-
void KeybindingSystem::changeModals() noexcept
665+
void KeybindingSystem::changeModals(bool& save) noexcept
666666
{
667667
if (ImGui::BeginPopupModal(TR_ID("CHANGE_KEY", Tr::CHANGE_KEY), 0, ImGuiWindowFlags_AlwaysAutoResize))
668668
{
@@ -673,7 +673,7 @@ void KeybindingSystem::changeModals() noexcept
673673
ImGui::Text(changeModalText.c_str());
674674
}
675675
if (!currentlyChanging) {
676-
//save = true; // autosave
676+
save = true; // autosave
677677
ImGui::CloseCurrentPopup();
678678
}
679679
ImGui::EndPopup();
@@ -682,7 +682,7 @@ void KeybindingSystem::changeModals() noexcept
682682
if (ImGui::BeginPopupModal(TR_ID("CHANGE_BUTTON", Tr::CHANGE_BUTTON))) {
683683
ImGui::TextUnformatted(TR(CHANGE_BUTTON_MSG));
684684
if (!currentlyChanging) {
685-
//save = true; // autosave
685+
save = true; // autosave
686686
ImGui::CloseCurrentPopup();
687687
}
688688
ImGui::EndPopup();
@@ -744,7 +744,7 @@ void KeybindingSystem::addBindingsGroup(KeybindingGroup& group, bool& save, bool
744744
}
745745
}
746746
ImGui::NextColumn();
747-
changeModals();
747+
changeModals(save);
748748
ImGui::PopID();
749749
}
750750

OFS-lib/UI/KeybindingSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class KeybindingSystem
227227
void addPassiveBindingGroup(PassiveBindingGroup& group, bool& save) noexcept;
228228
void passiveBindingTab(bool& save) noexcept;
229229

230-
void changeModals() noexcept;
230+
void changeModals(bool& save) noexcept;
231231
public:
232232
bool ShowWindow = false;
233233

OFS-lib/UI/OFS_ScriptTimeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ inline static float easeOutExpo(float x) noexcept {
250250

251251
void ScriptTimeline::Update() noexcept
252252
{
253-
auto timePassed = Util::Clamp((SDL_GetTicks() - visibleTimeUpdate) / 200.f, 0.f, 1.f);
253+
auto timePassed = Util::Clamp((SDL_GetTicks() - visibleTimeUpdate) / 150.f, 0.f, 1.f);
254254
timePassed = easeOutExpo(timePassed);
255255
visibleTime = Util::Lerp(previousVisibleTime, nextVisisbleTime, timePassed);
256256
}

src/OpenFunscripter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ OpenFunscripter::~OpenFunscripter()
131131
LoadedProject.reset();
132132

133133
settings->saveSettings();
134+
keybinds.save();
135+
134136
player.reset();
135137
events.reset();
136138
}

src/UI/OFS_Settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ bool OFS_Settings::ShowPreferenceWindow() noexcept
177177
OFS_Translator::ptr->LoadDefaults();
178178
}
179179
ImGui::SameLine();
180-
if(ImGui::Button(TR_ID("OPEN_DIR_LANG", Tr::DIRECTORY)))
180+
if(ImGui::Button(FMT("%s###DIRECTORY_TRANSLATION", ICON_FOLDER_OPEN)))
181181
{
182182
Util::OpenFileExplorer(Util::Prefpath(OFS_Translator::TranslationDir));
183183
}

src/lua/OFS_LuaCoreExtension.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ Spline.PointEveryMs = 100
2121
2222
function init()
2323
-- this runs once at when loading the extension
24-
ofs.Bind("jitter", "Adds jitter to selection.")
25-
ofs.Bind("random_noise", "Generates a random script.")
26-
ofs.Bind("spline_smooth", "Adds spline smoothing to selection.")
2724
print("initialized")
2825
end
2926
@@ -53,7 +50,7 @@ function gui()
5350
Random.MinStrokeDuration = ofs.Input("Min duration", Random.MinStrokeDuration)
5451
Random.MaxStrokeDuration = ofs.Input("Max duration", Random.MaxStrokeDuration)
5552
if ofs.Button("Add random noise") then
56-
random_noise()
53+
binding.random_noise()
5754
end
5855
5956
if ofs.Button("Select all") then
@@ -69,11 +66,11 @@ function gui()
6966
Spline.PointEveryMs, splineChanged = ofs.Slider("Point per ms", Spline.PointEveryMs, 20, 500)
7067
if splineChanged then
7168
ofs.Undo()
72-
spline_smooth()
69+
binding.spline_smooth()
7370
end
7471
end
7572
76-
function spline_smooth()
73+
function binding.spline_smooth()
7774
local catmullRom = function(v1, v2, v3, v4, s)
7875
s2 = s*s
7976
s3 = s*s*s
@@ -88,7 +85,7 @@ function spline_smooth()
8885
local script = ofs.Script(ofs.ActiveIdx())
8986
local actionCount = #script.actions
9087
91-
if not ofs.HasSelection(script) then
88+
if not script:hasSelection() then
9289
return
9390
end
9491
@@ -109,41 +106,43 @@ function spline_smooth()
109106
-- since lua doesn't have a continue,
110107
-- we use a goto + a label at the bottom of the loop
111108
if not action2.selected or not action3.selected then goto continue end
112-
109+
110+
113111
local startTime = action2.at
114112
local endTime = action3.at
115113
local duration = endTime - startTime;
116114
117-
pointCount = duration/Spline.PointEveryMs;
118-
119-
for i=1, pointCount, 1 do
120-
s = (i*Spline.PointEveryMs) / duration
121-
time_ms = math.floor(action2.at + (i*Spline.PointEveryMs))
115+
local pointEverySecond = Spline.PointEveryMs / 1000.0
116+
117+
pointCount = duration/pointEverySecond
118+
119+
for i=1, pointCount-1, 1 do
120+
s = (i*pointEverySecond) / duration
121+
time_ms = action2.at + (i*pointEverySecond)
122122
spline_pos = catmullRom(action1.pos, action2.pos, action3.pos, action4.pos, s)
123123
spline_pos = clamp(spline_pos, 0, 100)
124-
--ofs.AddAction(script, time_ms, spline_pos)
125124
table.insert( smoothedActions, {at=time_ms, pos=spline_pos} )
126125
end
127126
::continue::
128127
end
129128
130129
for idx, action in ipairs(smoothedActions) do
131-
ofs.AddAction(script, action.at, action.pos)
130+
script.actions:add(Action.new(action.at, action.pos))
132131
end
133-
ofs.Commit(script)
132+
script:commit()
134133
end
135134
136-
function random_noise()
135+
function binding.random_noise()
137136
local script = ofs.Script(ofs.ActiveIdx())
138-
ofs.ClearScript(script)
137+
script.actions:clear()
139138
140139
local LastTimeMs = 0
141140
local LastPos = 0
142141
local TotalTimeMs = player.Duration() * 1000.0
143142
144143
local goingUp = true
145144
while LastTimeMs < TotalTimeMs do
146-
ofs.AddAction(script, LastTimeMs, LastPos)
145+
script.actions:add(Action.new(LastTimeMs/1000.0, LastPos))
147146
148147
if goingUp then
149148
LastPos = LastPos + math.random(Random.MinStrokeLen, Random.MaxStrokeLen)
@@ -155,29 +154,29 @@ function random_noise()
155154
LastTimeMs = LastTimeMs + math.random(Random.MinStrokeDuration, Random.MaxStrokeDuration)
156155
end
157156
158-
ofs.Commit(script)
157+
script:commit()
159158
end
160159
161160
function select_all()
162161
local script = ofs.Script(ofs.ActiveIdx())
163162
for idx, action in ipairs(script.actions) do
164163
action.selected = true
165164
end
166-
ofs.Commit(script)
165+
script:commit()
167166
end
168167
169168
function select_none()
170169
local script = ofs.Script(ofs.ActiveIdx())
171170
for idx, action in ipairs(script.actions) do
172171
action.selected = false
173172
end
174-
ofs.Commit(script)
173+
script:commit()
175174
end
176175
177-
function jitter()
176+
function binding.jitter()
178177
local script = ofs.Script(ofs.ActiveIdx())
179178
180-
if not ofs.HasSelection(script) then
179+
if not script:hasSelection() then
181180
return
182181
end
183182
@@ -198,7 +197,7 @@ function jitter()
198197
action.pos = action.pos + pos_jitter_value
199198
end
200199
end
201-
ofs.Commit(script)
200+
script:commit()
202201
end
203202
)";
204203

0 commit comments

Comments
 (0)