Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1769 from reicast/skmp/refactorcast-2
Browse files Browse the repository at this point in the history
REFACTORCAST-2
  • Loading branch information
skmp authored Jan 26, 2020
2 parents 41817c0 + 1fc47d0 commit f2a9b24
Show file tree
Hide file tree
Showing 18 changed files with 397 additions and 345 deletions.
11 changes: 9 additions & 2 deletions libswirl/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int screen_dpi = 96;
static bool inited = false;
float scaling = 1;

GuiState gui_state = Main;
GuiState gui_state = Welcome;

bool settings_opening;
static bool touch_up;
Expand Down Expand Up @@ -233,6 +233,9 @@ std::unique_ptr<GUI> g_GUI;

struct ReicastUI_impl : GUI {

ImFont* font17;
ImFont* font64;

void Init()
{
if (inited)
Expand Down Expand Up @@ -306,7 +309,8 @@ struct ReicastUI_impl : GUI {
if (scaling > 1)
ImGui::GetStyle().ScaleAllSizes(scaling);

io.Fonts->AddFontFromMemoryCompressedTTF(roboto_medium_compressed_data, roboto_medium_compressed_size, 17 * scaling);
font17 = io.Fonts->AddFontFromMemoryCompressedTTF(roboto_medium_compressed_data, roboto_medium_compressed_size, 17 * scaling);
font64 = io.Fonts->AddFontFromMemoryCompressedTTF(roboto_medium_compressed_data, roboto_medium_compressed_size, 128 * scaling);
printf("Screen DPI is %d, size %d x %d. Scaling by %.2f\n", screen_dpi, screen_width, screen_height, scaling);
}

Expand All @@ -328,6 +332,9 @@ struct ReicastUI_impl : GUI {
{
switch (gui_state)
{
case Welcome:
gui_welcome(font64);
break;
case Settings:
gui_settings();
break;
Expand Down
4 changes: 3 additions & 1 deletion libswirl/gui/gui_partials.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ void gui_settings_advanced();
void gui_settings_social();
void gui_settings_about();

void gui_welcome(ImFont* font64);

void reset_vmus();

extern bool game_list_done;
Expand Down Expand Up @@ -41,6 +43,6 @@ extern f32 mo_wheel_delta;

extern int screen_dpi;

typedef enum { Closed, Commands, Settings, ClosedNoResume, Main, Onboarding, VJoyEdit, VJoyEditCommands } GuiState;
typedef enum { Welcome, Closed, Commands, Settings, ClosedNoResume, Main, Onboarding, VJoyEdit, VJoyEditCommands } GuiState;
extern GuiState gui_state;
void ImGui_Impl_NewFrame();
76 changes: 76 additions & 0 deletions libswirl/gui/gui_welcome.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include "types.h"
#include "version.h"
#include "gui.h"
#include "imgui/imgui.h"
#include "gui_partials.h"
#include "gui_util.h"
#include "rend/gles/imgui_impl_opengl3.h"
#include "cfg/cfg.h"
#include "oslib/oslib.h"

float CalcScreenScale(const char* headline) {
auto size = ImGui::CalcTextSize(headline);

float scale = 0;

scale = screen_width/(size.x + 10);

if (size.y * scale / screen_height > 0.4) {
scale = (screen_height * 0.4) / size.y;
}
return scale;
}

void DrawTextCentered(const char* text) {
auto size = ImGui::CalcTextSize(text);
ImGui::SetCursorPosX(screen_width/2 - size.x / 2);
ImGui::Text("%s", text);
}

void gui_welcome(ImFont* font64) {

static auto endTime = os_GetSeconds() + 3;

if (os_GetSeconds() > endTime) {
gui_state = Main;
return;
}

ImGui_Impl_NewFrame();
ImGui::NewFrame();

ImGui_ImplOpenGL3_DrawBackground();

ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowSize(ImVec2(screen_width, screen_height));

ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);

ImGui::PushFont(font64);
ImGui::Begin("Welcome", NULL, /*ImGuiWindowFlags_AlwaysAutoResize |*/ ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize);


ImGui::SetWindowFontScale(1);
float scale = CalcScreenScale("Reicast");

ImGui::SetWindowFontScale(scale);

DrawTextCentered("Reicast");

string ver = REICAST_VERSION;
auto ver_numeric = ver.substr(0, ver.find_last_of("-"));
auto ver_hash = "(" + ver.substr(ver.find_last_of("-") + 2) + ")";

ImGui::SetWindowFontScale(scale / 3.5);
DrawTextCentered(ver_numeric.c_str());

ImGui::SetWindowFontScale(scale / 6);
DrawTextCentered(ver_hash.c_str());

ImGui::End();
ImGui::PopFont();
ImGui::PopStyleVar();

ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData(), false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "types.h"
#include "hw/sh4/sh4_mem.h"

#include "hw/sh4/sh4_mem_area0.h"
#include "hw/holly/sh4_mem_area0.h"
#include "hw/holly/sb.h"
#include "hw/pvr/pvr_mem.h"
#include "hw/gdrom/gdrom_if.h"
Expand All @@ -18,7 +18,7 @@

#include "hw/flashrom/flashrom.h"
#include "reios/reios.h"
#include "sh4_mmio.h"
#include "hw/sh4/sh4_mmio.h"
#include "hw/sh4/SuperH4_impl.h"

#include <memory>
Expand Down Expand Up @@ -377,29 +377,6 @@ void DYNACALL WriteMem_area0(void* ctx, u32 addr,T data)
return;
}

//Init/Res/Term
bool sh4_area0_Init(SuperH4_impl* sh4)
{
for (const auto& dev : sh4->devices)
if (!dev->Init())
return false;

return true;
}

void sh4_area0_Reset(SuperH4_impl* sh4, bool Manual)
{
for (const auto& dev : sh4->devices)
dev->Reset(Manual);
}

void sh4_area0_Term(SuperH4_impl* sh4)
{
for (const auto& dev : sh4->devices)
dev->Term();
}


//AREA 0
_vmem_handler area0_handler;

Expand Down
7 changes: 7 additions & 0 deletions libswirl/hw/holly/sh4_mem_area0.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#include "types.h"

struct SuperH4;

void map_area0_init(SuperH4* sh4);
void map_area0(SuperH4* sh4, u32 base);
Loading

0 comments on commit f2a9b24

Please sign in to comment.