Skip to content

Commit

Permalink
Backend update from GZDoom.
Browse files Browse the repository at this point in the history
Mainly remembering the game list's initial setting.
  • Loading branch information
coelckers committed Jan 5, 2024
1 parent 35c22c5 commit 673a913
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 12 deletions.
2 changes: 2 additions & 0 deletions libraries/ZWidget/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(ZWIDGET_SOURCES
src/core/timer.cpp
src/core/widget.cpp
src/core/utf8reader.cpp
src/core/pathfill.cpp
src/core/schrift/schrift.cpp
src/core/schrift/schrift.h
src/core/picopng/picopng.cpp
Expand Down Expand Up @@ -38,6 +39,7 @@ set(ZWIDGET_INCLUDES
include/zwidget/core/font.h
include/zwidget/core/image.h
include/zwidget/core/rect.h
include/zwidget/core/pathfill.h
include/zwidget/core/span_layout.h
include/zwidget/core/timer.h
include/zwidget/core/widget.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ListView : public Widget

void AddItem(const std::string& text);
int GetSelectedItem() const { return selectedItem; }
void SetSelectedItem(int index);
void ScrollToItem(int index);

void Activate();
Expand Down
18 changes: 12 additions & 6 deletions libraries/ZWidget/src/widgets/listview/listview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ void ListView::Activate()
OnActivated();
}

void ListView::SetSelectedItem(int index)
{
if (selectedItem != index && index >= 0 && index < items.size())
{
selectedItem = index;
Update();
}
}

void ListView::ScrollToItem(int index)
{
double itemHeight = 20.0;
Expand Down Expand Up @@ -95,8 +104,7 @@ void ListView::OnMouseDown(const Point& pos, int key)
int index = (int)((pos.y - 5.0 + scrollbar->GetPosition()) / 20.0);
if (index >= 0 && (size_t)index < items.size())
{
selectedItem = index;
Update();
SetSelectedItem(index);
ScrollToItem(selectedItem);
}
}
Expand Down Expand Up @@ -128,17 +136,15 @@ void ListView::OnKeyDown(EInputKey key)
{
if (selectedItem + 1 < (int)items.size())
{
selectedItem++;
Update();
SetSelectedItem(selectedItem + 1);
}
ScrollToItem(selectedItem);
}
else if (key == IK_Up)
{
if (selectedItem > 0)
{
selectedItem--;
Update();
SetSelectedItem(selectedItem - 1);
}
ScrollToItem(selectedItem);
}
Expand Down
1 change: 0 additions & 1 deletion source/common/rendering/gl/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ FShaderCollection::FShaderCollection(EPassType passType)
{
mEffectShaders[i] = NULL;
}
CompileNextShader();
}

//==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion source/common/rendering/vulkan/shaders/vk_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool VkShaderManager::CompileNextShader()

VkShaderManager::VkShaderManager(VulkanRenderDevice* fb) : fb(fb)
{
CompileNextShader();
//CompileNextShader();
}

VkShaderManager::~VkShaderManager()
Expand Down
2 changes: 1 addition & 1 deletion source/common/utility/tarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ class TArray
Resize(i);
}

void push_back(T& elem)
void push_back(const T& elem)
{
Push(elem);
}
Expand Down
7 changes: 4 additions & 3 deletions source/core/gamecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,10 @@ int RunGame()
GetGames();
auto usedgroups = SetupGame();

V_InitScreenSize();
V_InitScreen();
V_Init2();

bool colorset = false;
for (int i = usedgroups.Size()-1; i >= 0; i--)
{
Expand Down Expand Up @@ -1109,8 +1113,6 @@ int RunGame()
auto ci = DumpCPUInfo(&CPU);
Printf("%s", ci.GetChars());

V_InitScreenSize();
V_InitScreen();
StartWindow = FStartupScreen::CreateInstance(8);
StartWindow->Progress();

Expand Down Expand Up @@ -1173,7 +1175,6 @@ int RunGame()
I_UpdateWindowTitle();
DeleteStartupScreen();

V_Init2();
while (!screen->CompileNextShader())
{
// here we can do some visual updates later
Expand Down
1 change: 1 addition & 0 deletions source/core/statusbar2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void ST_Clear()
ReservedSpace GetReservedScreenSpace(int viewsize)
{
ReservedSpace res{};
if (StatusBar == nullptr) return res;
IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, GetReservedScreenSpace)
{
VMReturn ret[2];
Expand Down
6 changes: 6 additions & 0 deletions source/launcher/launcherwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
GamesList->AddItem(work.GetChars());
}

if (defaultiwad >= 0 && defaultiwad < numwads)
{
GamesList->SetSelectedItem(defaultiwad);
GamesList->ScrollToItem(defaultiwad);
}

Logo->SetImage(Image::LoadResource("widgets/banner.png"));

GamesList->SetFocus();
Expand Down

0 comments on commit 673a913

Please sign in to comment.