mirror of
https://github.com/0ldsk00l/nestopia.git
synced 2024-06-22 06:02:26 -04:00
FLTK: Clean up main fltkui interface
This commit is contained in:
parent
eee60f7a5c
commit
ff32ec77d6
|
@ -53,23 +53,27 @@
|
|||
#include "fltkui_cheats.h"
|
||||
#include "fltkui_settings.h"
|
||||
|
||||
static int paused = 0;
|
||||
static int speed = 1;
|
||||
static int video_fullscreen = 0;
|
||||
namespace {
|
||||
|
||||
static NstWindow *nstwin;
|
||||
static Fl_Menu_Bar *menubar;
|
||||
static NstGlArea *glarea;
|
||||
static NstChtWindow *chtwin;
|
||||
static NstSettingsWindow *setwin;
|
||||
int paused{0};
|
||||
int speed{1};
|
||||
int video_fullscreen{0};
|
||||
|
||||
static JGManager *jgm = nullptr;
|
||||
static SettingManager *setmgr = nullptr;
|
||||
static InputManager *inputmgr = nullptr;
|
||||
static AudioManager *audiomgr = nullptr;
|
||||
static CheatManager *chtmgr = nullptr;
|
||||
NstWindow *nstwin{nullptr};
|
||||
Fl_Menu_Bar *menubar{nullptr};
|
||||
NstGlArea *glarea{nullptr};
|
||||
NstChtWindow *chtwin{nullptr};
|
||||
NstSettingsWindow *setwin{nullptr};
|
||||
|
||||
static std::vector<uint8_t> game;
|
||||
JGManager *jgm{nullptr};
|
||||
SettingManager *setmgr{nullptr};
|
||||
InputManager *inputmgr{nullptr};
|
||||
AudioManager *audiomgr{nullptr};
|
||||
CheatManager *chtmgr{nullptr};
|
||||
|
||||
std::vector<uint8_t> game;
|
||||
|
||||
}
|
||||
|
||||
static int fltkui_refreshrate(void) {
|
||||
// Get the screen refresh rate using an SDL window
|
||||
|
@ -156,7 +160,7 @@ static void fltkui_rom_open(Fl_Widget* w, void* userdata) {
|
|||
if (jgm->is_loaded()) {
|
||||
chtmgr->clear();
|
||||
chtwin->refresh();
|
||||
fltkui_enable_menu();
|
||||
FltkUi::enable_menu();
|
||||
nstwin->label(jgm->get_gamename().c_str());
|
||||
jg_setup_audio();
|
||||
jg_setup_video();
|
||||
|
@ -352,12 +356,12 @@ void NstGlArea::resize(int x, int y, int w, int h) {
|
|||
nst_video_resize(w, h);
|
||||
}
|
||||
|
||||
void fltkui_rehash() {
|
||||
void FltkUi::rehash() {
|
||||
nst_video_rehash();
|
||||
audiomgr->rehash();
|
||||
}
|
||||
|
||||
void fltkui_fullscreen(Fl_Widget *w, void *data) {
|
||||
void FltkUi::fullscreen(Fl_Widget *w, void *data) {
|
||||
if (!jgm->is_loaded()) {
|
||||
return;
|
||||
}
|
||||
|
@ -458,6 +462,10 @@ int NstWindow::handle(int e) {
|
|||
return Fl_Double_Window::handle(e);
|
||||
}
|
||||
|
||||
void NstGlArea::draw() {
|
||||
nst_ogl_render();
|
||||
}
|
||||
|
||||
int NstGlArea::handle(int e) {
|
||||
int xc, yc;
|
||||
switch (e) {
|
||||
|
@ -522,7 +530,7 @@ static Fl_Menu_Item menutable[] = {
|
|||
{"Pause", 0, fltkui_pause, 0, FL_MENU_DIVIDER|FL_MENU_INACTIVE},
|
||||
{"Reset (Soft)", 0, fltkui_reset, (void*)"0", FL_MENU_INACTIVE},
|
||||
{"Reset (Hard)", 0, fltkui_reset, (void*)"1", FL_MENU_DIVIDER|FL_MENU_INACTIVE},
|
||||
{"Fullscreen", 0, fltkui_fullscreen, 0, FL_MENU_DIVIDER|FL_MENU_INACTIVE},
|
||||
{"Fullscreen", 0, FltkUi::fullscreen, 0, FL_MENU_DIVIDER|FL_MENU_INACTIVE},
|
||||
{"Switch Disk Side", 0, fltkui_fds_next, 0, FL_MENU_INACTIVE},
|
||||
{"Insert/Eject Disk", 0, fltkui_fds_insert, 0, FL_MENU_DIVIDER|FL_MENU_INACTIVE},
|
||||
{"Cheats...", 0, fltkui_cheats, 0, FL_MENU_DIVIDER|FL_MENU_INACTIVE},
|
||||
|
@ -534,13 +542,13 @@ static Fl_Menu_Item menutable[] = {
|
|||
{0} // End Menu
|
||||
};
|
||||
|
||||
void fltkui_enable_menu() {
|
||||
void FltkUi::enable_menu() {
|
||||
for (int i = 0; i < menutable[0].size(); ++i) {
|
||||
menutable[i].activate();
|
||||
}
|
||||
}
|
||||
|
||||
void fltkui_show_msgbox(bool show) {
|
||||
void FltkUi::show_msgbox(bool show) {
|
||||
setwin->show_msgbox(show);
|
||||
}
|
||||
|
||||
|
@ -577,7 +585,7 @@ void makenstwin(const char *name) {
|
|||
nstwin->end();
|
||||
}
|
||||
|
||||
void fltkui_set_ffspeed(bool on) {
|
||||
void FltkUi::set_ffspeed(bool on) {
|
||||
if (on) {
|
||||
speed = setmgr->get_setting("m_ffspeed")->val;
|
||||
}
|
||||
|
@ -632,7 +640,7 @@ int main(int argc, char *argv[]) {
|
|||
//jgm->load_game(argv[argc - 1]);
|
||||
if (jgm->is_loaded()) {
|
||||
nstwin->label(jgm->get_gamename().c_str());
|
||||
fltkui_enable_menu();
|
||||
FltkUi::enable_menu();
|
||||
jg_setup_audio();
|
||||
jg_setup_video();
|
||||
inputmgr->reassign();
|
||||
|
@ -644,7 +652,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
if (video_fullscreen) {
|
||||
video_fullscreen = 0;
|
||||
fltkui_fullscreen(NULL, NULL);
|
||||
FltkUi::fullscreen(NULL, NULL);
|
||||
}
|
||||
|
||||
int frames = 0;
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <video.h>
|
||||
|
||||
#define UI_MBARHEIGHT 24
|
||||
#define UI_SPACING 24
|
||||
#define UI_ELEMHEIGHT 25
|
||||
#define UI_ELEMWIDTH 160
|
||||
#define UI_DIAL_LG 100
|
||||
#define UI_DIAL_SM 40
|
||||
constexpr Fl_Color NstGreen = 0x255f6500;
|
||||
constexpr Fl_Color NstPurple = 0x5f578700;
|
||||
constexpr Fl_Color NstRed = 0xb51e2c00;
|
||||
constexpr Fl_Color NstWhite = 0xffffff00;
|
||||
constexpr Fl_Color NstBlueGrey = 0x383c4a00;
|
||||
constexpr Fl_Color NstLightGrey = 0xd3dae300;
|
||||
constexpr int UI_MBARHEIGHT = 24;
|
||||
constexpr int UI_SPACING = 24;
|
||||
constexpr int UI_ELEMHEIGHT = 25;
|
||||
constexpr int UI_ELEMWIDTH = 160;
|
||||
constexpr int UI_DIAL_LG = 100;
|
||||
constexpr int UI_DIAL_SM = 40;
|
||||
|
||||
class NstWindow : public Fl_Double_Window {
|
||||
private:
|
||||
|
@ -23,7 +25,7 @@ public:
|
|||
|
||||
class NstGlArea : public Fl_Gl_Window {
|
||||
private:
|
||||
void draw() { nst_ogl_render(); }
|
||||
void draw();
|
||||
int handle(int e);
|
||||
|
||||
public:
|
||||
|
@ -34,17 +36,11 @@ public:
|
|||
void resize(int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
constexpr Fl_Color NstGreen = 0x255f6500;
|
||||
constexpr Fl_Color NstPurple = 0x5f578700;
|
||||
constexpr Fl_Color NstRed = 0xb51e2c00;
|
||||
constexpr Fl_Color NstWhite = 0xffffff00;
|
||||
constexpr Fl_Color NstBlueGrey = 0x383c4a00;
|
||||
constexpr Fl_Color NstLightGrey = 0xd3dae300;
|
||||
|
||||
void fltkui_rehash();
|
||||
void fltkui_fullscreen(Fl_Widget *w = nullptr, void *data = nullptr);
|
||||
void fltkui_enable_menu();
|
||||
void fltkui_set_ffspeed(bool on);
|
||||
void fltkui_show_msgbox(bool show);
|
||||
|
||||
std::string& fltkui_get_confpath();
|
||||
class FltkUi {
|
||||
public:
|
||||
static void enable_menu();
|
||||
static void rehash();
|
||||
static void set_ffspeed(bool on);
|
||||
static void show_msgbox(bool show);
|
||||
static void fullscreen(Fl_Widget *w = nullptr, void *data = nullptr);
|
||||
};
|
||||
|
|
|
@ -117,7 +117,7 @@ void NstSettingsWindow::cb_chooser(Fl_Widget *w, void *data) {
|
|||
setting->val = ((Fl_Choice*)w)->value();
|
||||
|
||||
if (setting->flags & FLAG_FRONTEND) {
|
||||
fltkui_rehash();
|
||||
FltkUi::rehash();
|
||||
}
|
||||
else {
|
||||
jgm.rehash();
|
||||
|
@ -137,7 +137,7 @@ void NstSettingsWindow::cb_slider(Fl_Widget *w, void *data) {
|
|||
setting->val = ((Fl_Hor_Value_Slider*)w)->value();
|
||||
|
||||
if (setting->flags & FLAG_FRONTEND) {
|
||||
fltkui_rehash();
|
||||
FltkUi::rehash();
|
||||
}
|
||||
else {
|
||||
jgm.rehash();
|
||||
|
|
|
@ -37,8 +37,6 @@
|
|||
|
||||
namespace {
|
||||
|
||||
UiAdapter uiadpt;
|
||||
|
||||
jg_inputstate_t coreinput[5];
|
||||
jg_inputinfo_t *inputinfo[5];
|
||||
|
||||
|
@ -478,16 +476,16 @@ void InputManager::ui_events() {
|
|||
jgm.state_qload(1);
|
||||
break;
|
||||
case 8: // Fullscreen
|
||||
uiadpt.fullscreen();
|
||||
UiAdapter::fullscreen();
|
||||
break;
|
||||
case 9: // Pause
|
||||
uiadpt.pause();
|
||||
UiAdapter::pause();
|
||||
break;
|
||||
case 10: // FastForward
|
||||
uiadpt.fastforward(false);
|
||||
UiAdapter::fastforward(false);
|
||||
break;
|
||||
case 11: // Screenshot
|
||||
uiadpt.screenshot();
|
||||
UiAdapter::screenshot();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +494,7 @@ void InputManager::ui_events() {
|
|||
}
|
||||
|
||||
if (uistate.button[10]) {
|
||||
uiadpt.fastforward(true);
|
||||
UiAdapter::fastforward(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,6 +573,6 @@ void InputManager::set_cfg_running(bool running) {
|
|||
cfg_running = running;
|
||||
if (!running) {
|
||||
// Turn off the message now
|
||||
uiadpt.show_msgbox(running);
|
||||
UiAdapter::show_msgbox(running);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
|
@ -34,15 +32,14 @@
|
|||
#include <FL/gl.h>
|
||||
|
||||
#include "fltkui.h"
|
||||
|
||||
#include "uiadapter.h"
|
||||
|
||||
void UiAdapter::fullscreen() {
|
||||
fltkui_fullscreen();
|
||||
FltkUi::fullscreen();
|
||||
}
|
||||
|
||||
void UiAdapter::fastforward(bool on) {
|
||||
fltkui_set_ffspeed(on);
|
||||
FltkUi::set_ffspeed(on);
|
||||
}
|
||||
|
||||
void UiAdapter::pause() {
|
||||
|
@ -52,5 +49,5 @@ void UiAdapter::screenshot() {
|
|||
}
|
||||
|
||||
void UiAdapter::show_msgbox(bool show) {
|
||||
fltkui_show_msgbox(show);
|
||||
FltkUi::show_msgbox(show);
|
||||
}
|
||||
|
|
|
@ -5,12 +5,11 @@ public:
|
|||
UiAdapter() {}
|
||||
~UiAdapter() {}
|
||||
|
||||
void fullscreen();
|
||||
void fastforward(bool ff);
|
||||
void pause();
|
||||
void screenshot();
|
||||
|
||||
void show_msgbox(bool show);
|
||||
static void fullscreen();
|
||||
static void fastforward(bool ff);
|
||||
static void pause();
|
||||
static void screenshot();
|
||||
static void show_msgbox(bool show);
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue