Files
birth1mark 1c7f357438 Fix dynamic window resizing/scaling and improve UI typography legibility
- Handled SDL_WINDOWEVENT in SDL2Host with dynamic viewport and DestR recalculation
- Fixed window resizing: game now scales smoothly and dynamically with window expansion
- Replaced unrenderable multi-byte UTF-8 emojis in DefaultCart with crisp ASCII and custom pixel-art badges
- Enhanced header tabs with high-contrast plates (* LOCAL * / * BBS GET *)
- Added dedicated prompt banner: PRESS [O] TO SWITCH TAB
- Redesigned bottom action legend with arcade button pills ([X] PLAY, [O] BBS/BACK, [<>] CARTS)
2026-10-22 19:34:55 +01:00

165 lines
3.3 KiB
C++

#pragma once
#include <stdio.h>
#include <vector>
#include <string>
#include "hostVmShared.h"
#include "Audio.h"
#if (defined(_WIN32) || defined(__WIN32__))
#include <direct.h> /* _mkdir */
#define mkdir(A, B) _mkdir(A)
#endif
enum StretchOption {
PixelPerfect,
PixelPerfectStretch,
StretchToFit,
StretchToFill,
StretchAndOverflow,
AltScreenPixelPerfect,
AltScreenStretch,
FourByThreeVertPerfect,
FourByThreeStretch
};
#if LOAD_PACK_INS
enum PackinLoadOption {
Unloaded,
Loaded
};
#endif
enum ResizekeyOption {
NoResize,
YesResize
};
enum KeyboardOption {
Emoji,
Lowercase
};
enum MenuStyleOption {
Classic,
Fancy,
Splore
};
enum BgColorOption {
Gray,
Black,
Blue,
Green,
Purple,
White
};
class Host {
uint8_t currKDown;
uint8_t currKHeld;
bool currKBDown = false;
std::string currKBKey = "";
bool lDown = false;
bool rDown = false;
bool stretchKeyPressed = false;
//settings
#if LOAD_PACK_INS
PackinLoadOption packinloaded = Unloaded;
#endif
StretchOption stretch = PixelPerfectStretch;
KeyboardOption kbmode = Emoji;
ResizekeyOption resizekey = YesResize;
MenuStyleOption menustyle = Classic;
BgColorOption bgcolor = Gray;
float scaleX = 1.0;
float scaleY = 1.0;
int mouseOffsetX = 0;
int mouseOffsetY = 0;
int quit = 0;
std::string _logFilePrefix;
std::string _customBiosLua;
std::string _cartDirectory;
void loadSettingsIni();
void saveSettingsIni();
std::string getCartDataFile(std::string cartDataKey);
Color _paletteColors[144];
public:
Host(int windowWidth = 0, int windowHeight = 0);
void setUpPaletteColors();
void oneTimeSetup(Audio* audio);
void unpackCarts();
void setTargetFps(int targetFps);
bool shouldRunMainLoop();
InputState_t scanInput();
bool shouldQuit();
void changeStretch();
void forceStretch(StretchOption newStretch);
void onWindowResized(int newWidth, int newHeight);
void waitForTargetFps();
void drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMode);
bool shouldFillAudioBuff();
void* getAudioBufferPointer();
size_t getAudioBufferSize();
void playFilledAudioBuffer();
void oneTimeCleanup();
double deltaTMs();
std::vector<std::string> listcarts();
void overrideLogFilePrefix(const char* newPrefix);
const char* logFilePrefix();
std::string customBiosLua();
std::string getCartDataFileContents(std::string cartDataKey);
void saveCartData(std::string cartDataKey, std::string contents);
size_t getFileContents(std::string fileName, char* buffer);
void writeBufferToFile(std::string cartDataKey, char* buffer, size_t length);
std::string getCartDirectory();
void setCartDirectory(std::string cartDirectory);
std::vector<std::string> listdirs();
//settings
int getSetting(std::string sname);
void setSetting(std::string sname, int sdata);
Color* GetPaletteColors();
void setPlatformParams(
int windowWidth,
int windowHeight,
uint32_t sdlWindowFlags,
uint32_t sdlRendererFlags,
uint32_t sdlPixelFormat,
std::string logFilePrefix,
std::string customBiosLua,
std::string cartDirectory);
};