Skip to content

Commit

Permalink
Optimize theme Lua slightly
Browse files Browse the repository at this point in the history
basically stop some things from updating for no reason, slow it down, etc
probably decent fps gain
this broke something with the ready button i think
  • Loading branch information
poco0317 committed Jul 26, 2019
1 parent a8b6e46 commit 634a529
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ t[#t + 1] = Def.ActorFrame {
self:SetUpdateFunction( function(self)
self:queuecommand("Highlight")
end)
self:SetUpdateFunctionInterval(0.05)
end,

LoadFont("Common Normal") ..
Expand Down
1 change: 1 addition & 0 deletions Themes/Til Death/BGAnimations/_PlayerInfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ t[#t + 1] =
BeginCommand = function(self)
self:queuecommand("Set")
self:SetUpdateFunction(highlight)
self:SetUpdateFunctionInterval(0.05)
end,
SetCommand = function(self)
if profile == nil then
Expand Down
12 changes: 10 additions & 2 deletions Themes/Til Death/BGAnimations/_chartpreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local yeet
local cd

local function UpdatePreviewPos(self)
if not self:IsVisible() then return end
if noteField and yeet and SCREENMAN:GetTopScreen():GetName() == "ScreenSelectMusic" or
noteField and yeet and SCREENMAN:GetTopScreen():GetName() == "ScreenNetSelectMusic" then
local pos = SCREENMAN:GetTopScreen():GetPreviewNoteFieldMusicPosition() / musicratio
Expand All @@ -36,7 +37,6 @@ local t = Def.ActorFrame {
Name = "ChartPreview",
InitCommand=function(self)
self:visible(false)
self:SetUpdateFunction(UpdatePreviewPos)
cd = self:GetChild("ChordDensityGraph"):visible(false):draworder(1000)
memehamstermax = self
end,
Expand All @@ -60,9 +60,17 @@ local t = Def.ActorFrame {
end,
hELPidontDNOKNOWMessageCommand=function(self)
SCREENMAN:GetTopScreen():DeletePreviewNoteField(self)
self:SetUpdateFunction(nil)
end,
ChartPreviewOffMessageCommand=function(self)
self:SetUpdateFunction(nil)
end,
ChartPreviewOnMessageCommand=function(self)
self:SetUpdateFunction(UpdatePreviewPos)
end,
NoteFieldVisibleMessageCommand = function(self)
self:visible(true)
self:visible(true)
self:SetUpdateFunction(UpdatePreviewPos)
cd:visible(true):y(20) -- need to control this manually -mina
cd:GetChild("cdbg"):diffusealpha(0) -- we want to use our position background for draw order stuff -mina
cd:queuecommand("GraphUpdate") -- first graph will be empty if we dont force this on initial creation
Expand Down
4 changes: 3 additions & 1 deletion Themes/Til Death/BGAnimations/_chorddensitygraph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ end
local t = Def.ActorFrame {
Name = "ChordDensityGraph",
InitCommand=function(self)
self:SetUpdateFunction(textmover)
cdg = self
end,
CurrentSongChangedMessageCommand = function(self)
Expand Down Expand Up @@ -120,9 +119,12 @@ t[#t+1] =
Name = "CDGraphDrawer",
GraphUpdateCommand = function(self)
if self:IsVisible() then
self:GetParent():SetUpdateFunction(textmover)
updateGraphMultiVertex(cdg, self)
self:GetParent():linear(0.3)
self:GetParent():diffusealpha(1)
else
self:GetParent():SetUpdateFunction(nil)
end
end
}
Expand Down
3 changes: 0 additions & 3 deletions Themes/Til Death/BGAnimations/_cursor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ t[#t + 1] =
}

local function Update(self)
t.InitCommand = function(self)
self:SetUpdateFunction(Update)
end
--self:GetChild("MouseXY"):settextf("X:%5.2f Y:%5.2f W:%5.2f",INPUTFILTER:GetMouseX(),INPUTFILTER:GetMouseY(),INPUTFILTER:GetMouseWheel())
if not PREFSMAN:GetPreference("Windowed") then
self:GetChild("Cursor"):xy(INPUTFILTER:GetMouseX(), INPUTFILTER:GetMouseY())
Expand Down
3 changes: 3 additions & 0 deletions Themes/Til Death/Scripts/10 Widgets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ Widg.Button = function(params)
local mainActor = params.texture and button.sprite.actor
button.bg.HighlightCommand = params.highlight and function(self)
mainActor = mainActor or self
if not self.enabled then return end
local isOver = params.highlightCondition(self)
if params.highlight.texture then
(button.highlightSprite.actor):visible(isOver)
Expand Down Expand Up @@ -542,10 +543,12 @@ Widg.Button = function(params)
button.SetText = button.settext
button.Enable = function(button)
button.enabled = true
(button.actor):SetUpdateFunction(highlight)
return (button.actor):visible(button.enabled)
end
button.Disable = function(button)
button.enabled = false
(button.actor):SetUpdateFunction(nil)
return (button.actor):visible(button.enabled)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ chat.ScreenChangedMessageCommand = function(self)
self:visible(false)
show = false
typing = false
s:setInterval(
s:setTimeout(
function()
self:visible(false)
end,
Expand Down
8 changes: 6 additions & 2 deletions src/Etterna/Screen/Others/ScreenSyncOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Etterna/Models/Songs/Song.h"

static bool previousGameplayState;
static float slowupdate = 0;

static bool
IsGameplay()
Expand Down Expand Up @@ -53,8 +54,11 @@ ScreenSyncOverlay::Update(float fDeltaTime)
}

Screen::Update(fDeltaTime);

UpdateText();
slowupdate += fDeltaTime;
if (slowupdate > 0.25f) {
slowupdate = 0.f;
UpdateText();
}
}

bool g_bShowAutoplay = true;
Expand Down
6 changes: 0 additions & 6 deletions src/arch/InputHandler/InputHandler_DirectInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,6 @@ InputHandler_DInput::UpdatePolled(
INPUTFILTER->UpdateCursorLocation(
static_cast<float>(cursorPos.x),
static_cast<float>(cursorPos.y));
INPUTFILTER->UpdateCursorLocation(
static_cast<float>(cursorPos.x),
static_cast<float>(cursorPos.y));

DeviceInput di(
dev,
Expand Down Expand Up @@ -589,9 +586,6 @@ InputHandler_DInput::UpdateBuffered(
INPUTFILTER->UpdateCursorLocation(
static_cast<float>(cursorPos.x),
static_cast<float>(cursorPos.y));
INPUTFILTER->UpdateCursorLocation(
static_cast<float>(cursorPos.x),
static_cast<float>(cursorPos.y));

DeviceButton mouseInput = DeviceButton_Invalid;

Expand Down

0 comments on commit 634a529

Please sign in to comment.