make screen rotation configurable. start making it all clean.
This commit is contained in:
parent
f2a5be6096
commit
35c3b34a09
|
@ -37,9 +37,10 @@
|
||||||
#include "../Platform.h"
|
#include "../Platform.h"
|
||||||
|
|
||||||
|
|
||||||
const int kScreenGap[] = {0, 1, 8, 64, 90, 128, -1};
|
const int kScreenRot[4] = {0, 1, 2, 3};
|
||||||
const int kScreenLayout[] = {0, 1, 2};
|
const int kScreenGap[6] = {0, 1, 8, 64, 90, 128};
|
||||||
const int kScreenSizing[] = {0, 1, 2, 3};
|
const int kScreenLayout[3] = {0, 1, 2};
|
||||||
|
const int kScreenSizing[4] = {0, 1, 2, 3};
|
||||||
|
|
||||||
|
|
||||||
uiWindow* MainWindow;
|
uiWindow* MainWindow;
|
||||||
|
@ -49,6 +50,11 @@ uiMenuItem* MenuItem_Pause;
|
||||||
uiMenuItem* MenuItem_Reset;
|
uiMenuItem* MenuItem_Reset;
|
||||||
uiMenuItem* MenuItem_Stop;
|
uiMenuItem* MenuItem_Stop;
|
||||||
|
|
||||||
|
uiMenuItem* MenuItem_ScreenRot[4];
|
||||||
|
uiMenuItem* MenuItem_ScreenGap[6];
|
||||||
|
uiMenuItem* MenuItem_ScreenLayout[3];
|
||||||
|
uiMenuItem* MenuItem_ScreenSizing[4];
|
||||||
|
|
||||||
SDL_Thread* EmuThread;
|
SDL_Thread* EmuThread;
|
||||||
int EmuRunning;
|
int EmuRunning;
|
||||||
volatile int EmuStatus;
|
volatile int EmuStatus;
|
||||||
|
@ -425,7 +431,7 @@ void SetupScreenRects(int width, int height)
|
||||||
{
|
{
|
||||||
bool horizontal = false;
|
bool horizontal = false;
|
||||||
bool sideways = false;
|
bool sideways = false;
|
||||||
ScreenRotation = 1; // TEST 1=90 CW 2=180 3=270
|
|
||||||
if (ScreenRotation == 1 || ScreenRotation == 3)
|
if (ScreenRotation == 1 || ScreenRotation == 3)
|
||||||
sideways = true;
|
sideways = true;
|
||||||
|
|
||||||
|
@ -465,7 +471,7 @@ ScreenRotation = 1; // TEST 1=90 CW 2=180 3=270
|
||||||
topscreen = &TopScreenRect;
|
topscreen = &TopScreenRect;
|
||||||
bottomscreen = &BottomScreenRect;
|
bottomscreen = &BottomScreenRect;
|
||||||
}
|
}
|
||||||
//horizontal = true; // TEST
|
|
||||||
if (horizontal)
|
if (horizontal)
|
||||||
{
|
{
|
||||||
// side-by-side
|
// side-by-side
|
||||||
|
@ -656,7 +662,7 @@ void OnAreaResize(uiAreaHandler* handler, uiArea* area, int width, int height)
|
||||||
|
|
||||||
|
|
||||||
void Run()
|
void Run()
|
||||||
{
|
{printf("go sonic go\n");
|
||||||
EmuRunning = 1;
|
EmuRunning = 1;
|
||||||
RunningSomething = true;
|
RunningSomething = true;
|
||||||
|
|
||||||
|
@ -822,6 +828,25 @@ void OnOpenInputConfig(uiMenuItem* item, uiWindow* window, void* blarg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OnSetScreenRotation(uiMenuItem* item, uiWindow* window, void* param)
|
||||||
|
{
|
||||||
|
int rot = *(int*)param;
|
||||||
|
|
||||||
|
int oldrot = ScreenRotation;
|
||||||
|
ScreenRotation = rot;
|
||||||
|
|
||||||
|
// TODO: adjust window size
|
||||||
|
if (rot == 1 || rot == 3)
|
||||||
|
uiControlSetMinSize(uiControl(MainDrawArea), 384, 256);
|
||||||
|
else
|
||||||
|
uiControlSetMinSize(uiControl(MainDrawArea), 256, 384);
|
||||||
|
|
||||||
|
SetupScreenRects(Config::WindowWidth, Config::WindowHeight);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
uiMenuItemSetChecked(MenuItem_ScreenRot[i], i==ScreenRotation);
|
||||||
|
}
|
||||||
|
|
||||||
void OnSetScreenGap(uiMenuItem* item, uiWindow* window, void* param)
|
void OnSetScreenGap(uiMenuItem* item, uiWindow* window, void* param)
|
||||||
{
|
{
|
||||||
int gap = *(int*)param;
|
int gap = *(int*)param;
|
||||||
|
@ -972,15 +997,29 @@ int main(int argc, char** argv)
|
||||||
menuitem = uiMenuAppendItem(menu, "Input config");
|
menuitem = uiMenuAppendItem(menu, "Input config");
|
||||||
uiMenuItemOnClicked(menuitem, OnOpenInputConfig, NULL);
|
uiMenuItemOnClicked(menuitem, OnOpenInputConfig, NULL);
|
||||||
uiMenuAppendSeparator(menu);
|
uiMenuAppendSeparator(menu);
|
||||||
|
{
|
||||||
|
uiMenu* submenu = uiNewMenu("Screen rotation");
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
char name[32];
|
||||||
|
sprintf(name, "%d", kScreenRot[i]*90);
|
||||||
|
MenuItem_ScreenRot[i] = uiMenuAppendItem(submenu, name);
|
||||||
|
uiMenuItemOnClicked(MenuItem_ScreenRot[i], OnSetScreenRotation, (void*)&kScreenRot[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
uiMenuAppendSubmenu(menu, submenu);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
uiMenu* submenu = uiNewMenu("Mid-screen gap");
|
uiMenu* submenu = uiNewMenu("Mid-screen gap");
|
||||||
|
|
||||||
for (int i = 0; kScreenGap[i] != -1; i++)
|
//for (int i = 0; kScreenGap[i] != -1; i++)
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
sprintf(name, "%d pixels", kScreenGap[i]);
|
sprintf(name, "%d pixels", kScreenGap[i]);
|
||||||
menuitem = uiMenuAppendItem(submenu, name);
|
MenuItem_ScreenGap[i] = uiMenuAppendItem(submenu, name);
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenGap, (void*)&kScreenGap[i]);
|
uiMenuItemOnClicked(MenuItem_ScreenGap[i], OnSetScreenGap, (void*)&kScreenGap[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiMenuAppendSubmenu(menu, submenu);
|
uiMenuAppendSubmenu(menu, submenu);
|
||||||
|
@ -988,26 +1027,26 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
uiMenu* submenu = uiNewMenu("Screen layout");
|
uiMenu* submenu = uiNewMenu("Screen layout");
|
||||||
|
|
||||||
menuitem = uiMenuAppendItem(submenu, "Natural");
|
MenuItem_ScreenLayout[0] = uiMenuAppendItem(submenu, "Natural");
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenLayout, (void*)&kScreenLayout[0]);
|
uiMenuItemOnClicked(MenuItem_ScreenLayout[0], OnSetScreenLayout, (void*)&kScreenLayout[0]);
|
||||||
menuitem = uiMenuAppendItem(submenu, "Vertical");
|
MenuItem_ScreenLayout[1] = uiMenuAppendItem(submenu, "Vertical");
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenLayout, (void*)&kScreenLayout[1]);
|
uiMenuItemOnClicked(MenuItem_ScreenLayout[1], OnSetScreenLayout, (void*)&kScreenLayout[1]);
|
||||||
menuitem = uiMenuAppendItem(submenu, "Horizontal");
|
MenuItem_ScreenLayout[2] = uiMenuAppendItem(submenu, "Horizontal");
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenLayout, (void*)&kScreenLayout[2]);
|
uiMenuItemOnClicked(MenuItem_ScreenLayout[2], OnSetScreenLayout, (void*)&kScreenLayout[2]);
|
||||||
|
|
||||||
uiMenuAppendSubmenu(menu, submenu);
|
uiMenuAppendSubmenu(menu, submenu);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
uiMenu* submenu = uiNewMenu("Screen sizing");
|
uiMenu* submenu = uiNewMenu("Screen sizing");
|
||||||
|
|
||||||
menuitem = uiMenuAppendItem(submenu, "Even");
|
MenuItem_ScreenSizing[0] = uiMenuAppendItem(submenu, "Even");
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenSizing, (void*)&kScreenSizing[0]);
|
uiMenuItemOnClicked(MenuItem_ScreenSizing[0], OnSetScreenSizing, (void*)&kScreenSizing[0]);
|
||||||
menuitem = uiMenuAppendItem(submenu, "Emphasize top");
|
MenuItem_ScreenSizing[1] = uiMenuAppendItem(submenu, "Emphasize top");
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenSizing, (void*)&kScreenSizing[1]);
|
uiMenuItemOnClicked(MenuItem_ScreenSizing[1], OnSetScreenSizing, (void*)&kScreenSizing[1]);
|
||||||
menuitem = uiMenuAppendItem(submenu, "Emphasize bottom");
|
MenuItem_ScreenSizing[2] = uiMenuAppendItem(submenu, "Emphasize bottom");
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenSizing, (void*)&kScreenSizing[2]);
|
uiMenuItemOnClicked(MenuItem_ScreenSizing[2], OnSetScreenSizing, (void*)&kScreenSizing[2]);
|
||||||
menuitem = uiMenuAppendItem(submenu, "Auto");
|
MenuItem_ScreenSizing[3] = uiMenuAppendItem(submenu, "Auto");
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenSizing, (void*)&kScreenSizing[3]);
|
uiMenuItemOnClicked(MenuItem_ScreenSizing[3], OnSetScreenSizing, (void*)&kScreenSizing[3]);
|
||||||
|
|
||||||
uiMenuAppendSubmenu(menu, submenu);
|
uiMenuAppendSubmenu(menu, submenu);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue