This commit is contained in:
DepressedTWM 2026-08-02 14:50:33 +04:00
parent 24380ac4eb
commit 6bcf17ea55
9 changed files with 58 additions and 26 deletions

View file

@ -582,12 +582,7 @@ static void mriBindingExecute(){
* but not doing it will lead to crashes due to closed
* stdio streams on some platforms (eg. Windows) */
int argc = 0;
<<<<<<< HEAD
char **argv = 0;
=======
char **argv = nullptr;
//options_argv3[] = "--jit"
>>>>>>> b9cd221a9e6e6586cc4ca23a2b2d315b074f14e7
char options_argv1[] = "oneshot", options_argv2[] = "-ev";
char* options_argv[] = {options_argv1, options_argv2, NULL};
ruby_sysinit(&argc, &argv);

View file

@ -133,6 +133,15 @@ RB_METHOD(graphicsWait){
return Qnil;
}
RB_METHOD(graphicsSetVsync){
RB_UNUSED_PARAM;
int xuinia_ebania;
rb_get_args(argc, argv, "i", &xuinia_ebania RB_ARG_END);
shState->graphics().setVsync(xuinia_ebania);
return Qnil;
}
RB_METHOD(graphicsFadeout){
RB_UNUSED_PARAM;
@ -284,7 +293,7 @@ void graphicsBindingInit(){
_rb_define_module_function(module, "freeze", graphicsFreeze);
_rb_define_module_function(module, "transition", graphicsTransition);
_rb_define_module_function(module, "frame_reset", graphicsFrameReset);
_rb_define_module_function(module, "setVsync", graphicsSetVsync);
_rb_define_module_function(module, "__reset__", graphicsReset);
// Variables

View file

@ -16,6 +16,7 @@ module Settings
:twm_shader => true,
:light => true,
:scaling_mode => 0,
:vsync => 0,
# UI
:in_game_timer => false,
@ -205,6 +206,12 @@ class Window_Settings
:parameter => :scaling_mode,
:values => ["Nearest Neighbor", "Smooth(old)"]
},
{
:type => :enum,
:name => "Vsync mode",
:parameter => :vsync,
:values => ["Normal", "Adaptive", "Disabled"]
},
{ :type => :sep, :name => "Effects"},
{
:type => :bool,
@ -517,37 +524,37 @@ class Window_Settings
{
:type => :bool,
:name => "Show debug character",
:parameter => :debug_character
:parameter => :debug_character,
:icon => [1, 0],
},
{
:type => :bool,
:name => "Draw debug text in main menu",
:parameter => :debug_text_scene_title
:parameter => :debug_text_scene_title,
:icon => [1, 0],
},
{
:type => :bool,
:name => "Show debug text",
:parameter => :debug_text
:parameter => :debug_text,
:icon => [1, 0],
},
{
:type => :bool,
:name => "Show picture names",
:parameter => :debug_picture_names
:parameter => :debug_picture_names,
:icon => [1, 0],
},
{
:type => :bool,
:name => "Debug lightmap",
:parameter => :debug_lightmap
:parameter => :debug_lightmap,
:icon => [1, 0],
},
{
:type => :bool,
:name => "SDL_HINT_SHUTDOWN_DBUS_ON_QUIT",
:parameter => :SDL_HINT_SHUTDOWN_DBUS_ON_QUIT
:parameter => :SDL_HINT_SHUTDOWN_DBUS_ON_QUIT,
:icon => [1, 0],
},
{ :type => :sep },
@ -555,14 +562,14 @@ class Window_Settings
:type => :key,
:name => "Debug",
:parameter => :controls_debug,
:bind => Input::DEBUGACTION
:bind => Input::DEBUGACTION,
:icon => [1, 0],
},
{ :type => :sep },
{
:type => :action,
:name => "Clear image cache",
:action => Proc.new { RPG::Cache.clear }
:action => Proc.new { RPG::Cache.clear },
:icon => [1, 0],
}
],

View file

@ -22,7 +22,6 @@ begin
Font.default_size = 20
#debug shit
Input.set_led(255, 150, 30)
# Load persistent data
Persistent.load

View file

@ -77,6 +77,16 @@ module Settings
end
end
def vsync(value)
if value == 0
Graphics.setVsync(1)
elsif value == 1
Graphics.setVsync(-1)
else
Graphics.setVsync(0)
end
end
def SDL_HINT_SHUTDOWN_DBUS_ON_QUIT(value)
if value
Sunshine.setSDLHint("SDL_HINT_SHUTDOWN_DBUS_ON_QUIT", "1")

View file

@ -33,6 +33,7 @@
#include <SDL3/SDL_touch.h>
#include <SDL3/SDL_rect.h>
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_video.h>
#include "sharedstate.h"
#include "graphics.h"
@ -84,7 +85,8 @@ enum{
REQUEST_WINMOVETO,
REQUEST_MESSAGEBOX,
REQUEST_SETCURSORVISIBLE,
REQUEST_VSYNC,
UPDATE_FPS,
UPDATE_SCREEN_RECT,
@ -96,15 +98,13 @@ SDL_Gamepad* gc = nullptr;
bool EventThread::allocUserEvents(){
usrIdStart = SDL_RegisterEvents(EVENT_COUNT);
// SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events.
if (usrIdStart == (uint32_t) 0)
return false;
return true;
}
EventThread::EventThread()
: fullscreen(false), showCursor(true){}
EventThread::EventThread(): fullscreen(false), showCursor(true){}
void EventThread::process(RGSSThreadData &rtData){
SDL_Event event;
@ -412,8 +412,10 @@ void EventThread::process(RGSSThreadData &rtData){
default :
/* Handle user events */
switch(event.type - usrIdStart)
{
switch(event.type - usrIdStart){
case REQUEST_VSYNC:
SDL_GL_SetSwapInterval(event.user.code);
break;
case REQUEST_SETFULLSCREEN :
setFullscreen(win, static_cast<bool>(event.user.code));
break;
@ -511,10 +513,6 @@ bool EventThread::eventFilter(void *data, SDL_Event *event){
Debug() << "SDL_EVENT_TERMINATING";
return 0;
case SDL_EVENT_LOW_MEMORY :
Debug() << "SDL_EVENT_LOW_MEMORY";
return 0;
/* Workaround for Windows pausing on drag */
default:
if (event->window.type == SDL_EVENT_WINDOW_MOVED){
@ -579,6 +577,13 @@ void EventThread::requestFullscreenMode(bool mode){
SDL_PushEvent(&event);
}
void EventThread::requestVsync(int interval){
SDL_Event event;
event.type = usrIdStart + REQUEST_VSYNC;
event.user.code = interval;
SDL_PushEvent(&event);
}
void EventThread::requestWindowMove(int x, int y){
SDL_Event event;
event.type = usrIdStart + REQUEST_WINMOVETO;

View file

@ -96,7 +96,8 @@ public:
void requestWindowMove(int x, int y);
void requestWindowResize(int width, int height);
void requestShowCursor(bool mode);
void requestVsync(int interval);
void requestTerminate();
Vec2i getWindowPosition() const;

View file

@ -958,6 +958,10 @@ void Graphics::setFullscreen(bool value){
p->threadData->ethread->requestFullscreenMode(value);
}
void Graphics::setVsync(int value){
p->threadData->ethread->requestVsync(value);
}
bool Graphics::getSmooth() const{
return p->threadData->config.smoothScaling;
}

View file

@ -58,6 +58,8 @@ public:
void reset();
void setVsync(int value);
/* Non-standard extension */
DECL_ATTR( Fullscreen, bool )
DECL_ATTR( ShowCursor, bool )