diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b446b4..b5f0cc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,7 @@ set(MAIN_HEADERS src/signals/signal.h src/signals/signalconnection.h src/signals/rubydispatcher.h + src/signals/maindispatcher.h ) set(MAIN_SOURCE @@ -129,6 +130,7 @@ set(MAIN_SOURCE src/sunshine.cpp src/lightmap.cpp src/signals/rubydispatcher.cpp + src/signals/maindispatcher.cpp ) if(WIN32) diff --git a/PEOPLES.md b/PEOPLES.md index 3ed7622..80d92c3 100644 --- a/PEOPLES.md +++ b/PEOPLES.md @@ -10,6 +10,7 @@ Artists: * DesMo * Обси * DepressedTWM +* K1RMAN Testers: * Rubik diff --git a/README.md b/README.md index 58e6822..e341909 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,35 @@ # mkxp-sunshine -This is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) designed for OneShot: sunshine mod. +This is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) designed for OneShot: Sunshine mod. Target of sunshine mod - improve original game. -# xScripts.rxdata +## xScripts.rxdata + ./rpgscript.rb scripts/ [GameDir] -# Build -1.Install required packages -* Cmake -* C/C++ compiler -* xxd -* Ruby 3+ -* Boost -* SDL3 -* pixman -* SDL3_image -* SDL3_ttf -* [SDL3_sound](https://github.com/icculus/SDL_sound) -* OpenAL -* PhysFS -* sigc++-2.0 -* OpenSSL -* libzip -* GTK3(Linux only!) -* libxfconf(Linux only!) +## Build -2.build +1. Install required packages + * Cmake + * C/C++ compiler + * xxd + * Ruby 3+ + * Boost + * SDL3 + * pixman + * SDL3_image + * SDL3_ttf + * [SDL3_sound](https://github.com/icculus/SDL_sound) + * OpenAL + * PhysFS + * sigc++-2.0 + * OpenSSL + * libzip + * GTK3(Linux only!) + * libxfconf(Linux only!) -* In project dir create build dir -* cmake -S . -B build -* cd build -* make -jn (n - count of threads for compilation) +2. build + * In project dir create build dir + * cmake -S . -B build + * cd build + * make -jn (n - count of threads for compilation) diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index 364e302..e0fe38c 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -297,5 +297,5 @@ void graphicsBindingInit(){ INIT_GRA_PROP_BIND( Frameskip, "frameskip" ); const Config &conf = shState->rtData().config; - rb_define_const(module, "RESOLUTION_ASPECT", rb_str_new_cstr(conf.AspectPresetRubyConst.c_str())); + rb_define_const(module, "RESOLUTION_OVERRIDDEN", rb_bool_new(conf.resolutionOverridden)); } diff --git a/binding-mri/module_rpg1.rb b/binding-mri/module_rpg1.rb index 88c6f74..8227030 100644 --- a/binding-mri/module_rpg1.rb +++ b/binding-mri/module_rpg1.rb @@ -17,10 +17,7 @@ module RPG module Cache @cache = {} def self.load_bitmap(folder_name, filename, hue = 0) - path = folder_name + filename - if File.exist?(folder_name + filename + Graphics::RESOLUTION_ASPECT + ".png") - path += Graphics::RESOLUTION_ASPECT - end + path = Graphics.adapted_file(folder_name + filename) if not @cache.include?(path) or @cache[path].disposed? if filename != "" @cache[path] = Bitmap.new(path) diff --git a/changelogs/0.1.1.txt b/changelogs/0.1.1.txt index c156583..8afe015 100644 --- a/changelogs/0.1.1.txt +++ b/changelogs/0.1.1.txt @@ -67,3 +67,5 @@ main viewport resize, main window resize and move signals bindings for ruby Dynamic resolution support (WIP) Rewrited to use SDL3 libc methods instead default Removed useless debug logs +Glen reworked +GLLogger \n bug fix diff --git a/libraries.rb b/libraries.rb old mode 100644 new mode 100755 diff --git a/make-appimage.sh b/make-appimage.sh old mode 100644 new mode 100755 diff --git a/make-journal-linux.sh b/make-journal-linux.sh old mode 100644 new mode 100755 index 67ffeb3..d9a32ff --- a/make-journal-linux.sh +++ b/make-journal-linux.sh @@ -1,5 +1,6 @@ #!/bin/bash -eu + if [ $# -lt 2 ]; then echo "usage: make-journal-linux.sh SOURCE_PATH OUTPUT_DIR" exit 1 diff --git a/make-oneshot-linux.sh b/make-oneshot-linux.sh index 09b9843..8b33835 100755 --- a/make-oneshot-linux.sh +++ b/make-oneshot-linux.sh @@ -1,5 +1,4 @@ #!/bin/sh -#set -e set -euo pipefail cd `dirname $0` diff --git a/mklang.rb b/mklang.rb old mode 100644 new mode 100755 diff --git a/mklangsrc.rb b/mklangsrc.rb old mode 100644 new mode 100755 diff --git a/oneshot.conf b/oneshot.conf index 35c6a5a..305310e 100644 --- a/oneshot.conf +++ b/oneshot.conf @@ -25,25 +25,11 @@ printFPS=false # as opposed to stretch-to-fill fixedAspectRatio=true -# Set Monitor Aspect preset -# Value, Aspect, Window Resolusion -# (ratio and resolution are not acceptable values) -# Where X - not recommended, the correctness of -# the game is not guaranteed. -# 0 - 3:2 - 720:480 -# 1 - 4:3 - 640x480 (default) -# 2 - 16:9 - 960x540 -# 3 - 16:10 - 960x600 -# 4 - 16:9 HD - 1280x720 X -# 5 - 16:9 FHD - 1920x1080 X -AspectPreset=1 - -# Controlling the resolution of the game window, -# it is not recommended to change. -# If you want to configure 16:9 or any other, -# use AspectPreset. -# defScreenW=0 -# defScreenH=0 +# Controlling the resolution of the game window, +# and disables resolution setting in game, +# it is not recommended to change. +defScreenW=0 +defScreenH=0 # Apply linear interpolation when game screen # is upscaled diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 59a442e..a533a70 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -84,8 +84,9 @@ set(scripts Window_TPtL.rb Settings.rb Input.rb - DynamicLight.rb - Gamepad_Colors.rb) + Dynamic_Light.rb + Gamepad_Colors.rb + Dynamic_Resolution.rb) find_program(RUBY_EXE ruby DOC "Location of the Ruby executable") diff --git a/scripts/Data_Settings.rb b/scripts/Data_Settings.rb index be7e10c..2073816 100644 --- a/scripts/Data_Settings.rb +++ b/scripts/Data_Settings.rb @@ -8,6 +8,7 @@ module Settings # Video :fullscreen => false, + :resolution => 0, :colorblind => false, :frameskip => true, :twm_shader => true, @@ -142,6 +143,13 @@ class Window_Settings :name => tr('Fullscreen'), :parameter => :fullscreen }, + { + :type => :enum, + :name => tr('Resolution'), + :default => 0, + :parameter => Graphics::RESOLUTION_OVERRIDDEN ? nil : :resolution, + :values => Graphics::RESOLUTION_OVERRIDDEN ? ["Resolution is redefined via config"] : Graphics.resolutions_names_list + }, { :type => :bool, :name => tr('Colorblind mode'), diff --git a/scripts/Data_Settings_Classes.rb b/scripts/Data_Settings_Classes.rb index ebc1278..67c2be8 100644 --- a/scripts/Data_Settings_Classes.rb +++ b/scripts/Data_Settings_Classes.rb @@ -18,16 +18,19 @@ class Window_Settings attr_reader :viewport attr_reader :offset - def initialize(viewport, offset_y) + def initialize(viewport, offset_y, screen = 0, index = 0) + Window_Settings.send(:remove_const, :PARAMETER_WIDTH) + Window_Settings.const_set(:PARAMETER_WIDTH, (Graphics.width - 640) / 2 + 512) # костыль бля + @viewport = viewport - @screen = 0 - @index = 0 + @screen = screen + @index = index @opacity = 255 @offset = offset_y @waiting_for_key = false @wait_timer = 0 - @visible_x = 0 + @visible_x = @screen * Graphics.width @visible_y = offset_y @x = (Graphics.width - PARAMETER_WIDTH) / 2 @y = offset_y @@ -36,7 +39,7 @@ class Window_Settings @selection_sprite.bitmap = Bitmap.new(PARAMETER_WIDTH + 16, PARAMETER_HEIGHT) @selection_sprite.bitmap.fill_rect(Rect.new(0, 0, PARAMETER_WIDTH + 16, PARAMETER_HEIGHT), Color.new(255, 255, 255, 64)) @selection_sprite.x = @x - 8 - @selection_sprite.y = @offset + @selection_sprite.y = @index * PARAMETER_HEIGHT + @y @selection_sprite.blend_type = 1 @selection_sprite.z = 1 diff --git a/scripts/Data_Settings_Setters.rb b/scripts/Data_Settings_Setters.rb index 5d74155..591474f 100644 --- a/scripts/Data_Settings_Setters.rb +++ b/scripts/Data_Settings_Setters.rb @@ -20,6 +20,17 @@ module Settings def fullscreen(value) Graphics.fullscreen = $console = value end + def resolution(value) + if (!Graphics::RESOLUTION_OVERRIDDEN) + res_data = Graphics::RESOLUTIONS&.[](value) || {:width => 480, :height => 640} + old_width = Graphics.width + old_height = Graphics.height + new_width = res_data[:width] + new_height = res_data[:height] + Graphics.move_screen(Graphics.x - (new_width - old_width) / 2, Graphics.y - (new_height - old_height) / 2) + Graphics.resize_screen(new_width, new_height) + end + end def colorblind(value) $game_switches[252] = value end diff --git a/scripts/DynamicLight.rb b/scripts/Dynamic_Light.rb similarity index 100% rename from scripts/DynamicLight.rb rename to scripts/Dynamic_Light.rb diff --git a/scripts/Dynamic_Resolution.rb b/scripts/Dynamic_Resolution.rb new file mode 100644 index 0000000..beb150a --- /dev/null +++ b/scripts/Dynamic_Resolution.rb @@ -0,0 +1,48 @@ +module Graphics +# 0 - 3:2 - 720x480 +# 1 - 4:3 - 640x480 (default) +# 2 - 16:9 - 960x540 +# 3 - 16:10 - 960x600 + RESOLUTIONS = [ + { + :display_name => "4:3 - 640x480", + :file_tag => "_4_3", + :width => 640, + :height => 480, + }, + { + :display_name => "3:2 - 720x480", + :file_tag => "_3_2", + :width => 720, + :height => 480, + }, + { + :display_name => "16:9 - 960x540", + :file_tag => "_16_9", + :width => 960, + :height => 540, + }, + { + :display_name => "16:10 - 960x600", + :file_tag => "_16_10", + :width => 960, + :height => 600, + }, + ] + + def self.resolutions_names_list + list = [] + RESOLUTIONS.each do |res_data| + list << res_data[:display_name] + end + list + end + + def self.adapted_file(path, extention = ".png") + file_tag = RESOLUTIONS[Settings[:resolution] || 999]&.[](:file_tag) || "" + if File.exist?(path + file_tag + extention) + path + file_tag + end + path + end +end \ No newline at end of file diff --git a/scripts/Settings.rb b/scripts/Settings.rb index 1dbe6f4..89a8e6f 100644 --- a/scripts/Settings.rb +++ b/scripts/Settings.rb @@ -3,7 +3,7 @@ module Settings class << self def [](k) - @data[k] + @data&.[](k) end def []=(k, v) diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb index e35d49f..3b2143f 100644 --- a/scripts/Window_Settings.rb +++ b/scripts/Window_Settings.rb @@ -10,8 +10,10 @@ class Window_Settings @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 9998 @bg = Sprite.new(@viewport) - @bg.bitmap = Bitmap.new(Graphics.width, Graphics.height) - @bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0, 196)) + @bg.bitmap = Bitmap.new(1, 1) + @bg.bitmap.fill_rect(0, 0, 1, 1, Color.new(0, 0, 0, 196)) + @bg.zoom_x = Graphics.width + @bg.zoom_y = Graphics.height @title = Sprite.new(@viewport) @title.bitmap = Bitmap.new(320, 20) @title.bitmap.font.size = 20 @@ -27,9 +29,11 @@ class Window_Settings if self.visible @viewport.rect.width = w @viewport.rect.height = h - @bg.bitmap.dispose - @bg.bitmap = Bitmap.new(w, h) - @bg.bitmap.fill_rect(0, 0, w, h, Color.new(0, 0, 0, 196)) + @bg.zoom_x = w + @bg.zoom_y = h + #@bg.bitmap.dispose + #@bg.bitmap = Bitmap.new(w, h) + #@bg.bitmap.fill_rect(0, 0, w, h, Color.new(0, 0, 0, 196)) @title.x = (w - @title.bitmap.width) / 2 init_content else @@ -50,11 +54,15 @@ class Window_Settings end def init_content + old_screen = 0 + old_index = 0 if (@content) + old_screen = @content.screen + old_index = @content.index @content.dispose end - @content = SettingsContent.new(@viewport, TITLE_TOP_MARGIN + TITLE_MARGIN + 100) + @content = SettingsContent.new(@viewport, TITLE_TOP_MARGIN + TITLE_MARGIN + 100, old_screen, old_index) DATA.each_with_index do |(screen_title, parameters_info), screen_index| @content.add_screen(screen_title) diff --git a/scripts/_scripts.txt b/scripts/_scripts.txt index c438825..c7a0202 100644 --- a/scripts/_scripts.txt +++ b/scripts/_scripts.txt @@ -31,6 +31,8 @@ Game_Light Settings Input Gamepad_Colors +Dynamic_Resolution +Dynamic_Light Sprite_Character Sprite_Picture @@ -103,7 +105,6 @@ Doc_Message Desktop_Message Credits_Message Particles -DynamicLight EdText Main diff --git a/scripts/i18n_Language.rb b/scripts/i18n_Language.rb index 7c09ab3..18e93ea 100644 --- a/scripts/i18n_Language.rb +++ b/scripts/i18n_Language.rb @@ -12,7 +12,6 @@ class Language def set(lc) @data = nil @tr = nil - script = nil [lc.full.to_s, lc.lang.to_s].each do |name| path = "Languages/#{name}.po" if FileTest.exist?(path) @@ -35,36 +34,36 @@ class Language str.chars.each do |c| if not string_began string_began = true if c == '"' - next + next end - + next if c == "\n" next if c == "\r" - + if not escape break if c == '"' if c == '\\' - escape = true - next - end - else - escape = false - case c - when 'n' - unescaped.push("\n") - when 'r' - unescaped.push("\r") - else - unescaped.push(c) - end - next - end - + escape = true + next + end + else + escape = false + case c + when 'n' + unescaped.push("\n") + when 'r' + unescaped.push("\r") + else + unescaped.push(c) + end + next + end + unescaped.push(c) - end - - return unescaped.join('') - end + end + + return unescaped.join('') + end def load_pot(path) msgid = nil diff --git a/src/config.cpp b/src/config.cpp index a0db3ea..62e10fa 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -72,11 +72,11 @@ void Config::read(int argc, char *argv[]){ PO_DESC(printFPS, bool, false) \ PO_DESC(fullscreen, bool, false) \ PO_DESC(fixedAspectRatio, bool, true) \ - PO_DESC(AspectPreset, int, 1) \ + /*PO_DESC(AspectPreset, int, 1)*/ \ PO_DESC(smoothScaling, bool, false) \ PO_DESC(vsync, bool, true) \ - PO_DESC(defScreenW, int, 640) \ - PO_DESC(defScreenH, int, 480) \ + PO_DESC(defScreenW, int, 0) \ + PO_DESC(defScreenH, int, 0) \ PO_DESC(windowTitle, std::string, "") \ PO_DESC(commonDataPath, std::string, "") \ PO_DESC(Modloader.ModsDirPath, std::string,"mods") \ @@ -181,6 +181,10 @@ void Config::read(int argc, char *argv[]){ game.title = "OneShot: Sunshine"; game.scripts = "Data/xScripts.rxdata"; + resolutionOverridden = defScreenW > 0 || defScreenH > 0; + defScreenW = defScreenW <= 0 ? 640 : defScreenW; + defScreenH = defScreenH <= 0 ? 480 : defScreenH; +/* #define ASPECT_SELECT(id, x, y, rubyConst) \ case id: { \ defScreenW = x; \ @@ -202,7 +206,7 @@ void Config::read(int argc, char *argv[]){ } #undef ASPECT_SELECT - +*/ #ifdef STEAM /* Override fullscreen config if Big Picture */ if (const char *env = SDL_getenv("SteamTenfoot")){ diff --git a/src/config.h b/src/config.h index 5a0a131..1c251eb 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,7 @@ struct Config{ bool printFPS; bool fullscreen; bool fixedAspectRatio; + bool resolutionOverridden; bool Windows_AllocConsole; bool smoothScaling; bool vsync; @@ -51,8 +52,8 @@ struct Config{ int maxTextureSize; std::string gameFolder; - int AspectPreset; - std::string AspectPresetRubyConst; + //int AspectPreset; + //std::string AspectPresetRubyConst; bool allowSymlinks; bool pathCache; diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 544c40e..c93221c 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -180,6 +180,9 @@ void EventThread::process(RGSSThreadData &rtData){ SDL_GetWindowPosition(win, &rtData.ethread->winX, &rtData.ethread->winY); while (true) { + if (shState != nullptr) + shState->mainDispatcher().process(); + if (!SDL_WaitEvent(&event)) { Debug() << "[EventThread::process] Event error:\n" << SDL_GetError(); break; diff --git a/src/gl-debug.cpp b/src/gl-debug.cpp index 8cdd284..3fa2512 100644 --- a/src/gl-debug.cpp +++ b/src/gl-debug.cpp @@ -38,8 +38,12 @@ struct GLDebugLoggerPrivate{ ~GLDebugLoggerPrivate(){} void writeTimestamp(){ + //https://stackoverflow.com/questions/9628637/how-can-i-get-rid-of-n-from-string-in-c time(×tamp); - *stream << "[GLDEBUG] [" << ctime(×tamp) << "]"; + char *foo = ctime(×tamp); + if (strlen(foo) > 0) // i dont want segfault, im afraid of it >m< + foo[strlen(foo) - 1] = '\0'; + *stream << "[GLDEBUG] [" << foo << "] "; } void writeLine(const char *line){ diff --git a/src/main.cpp b/src/main.cpp index 45fe320..c111aeb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -336,8 +336,6 @@ int main(int argc, char *argv[]){ * dealing with icons; don't interfere with them */ #ifdef unix_like setupWindowIcon(conf, win); -#elif __EMSCRIPTEN__ - Debug() << "meow"; #else (void) setupWindowIcon; #endif diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index 538723f..070eac3 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -57,7 +57,7 @@ struct SharedStatePrivate{ Scene *screen; RubyDispatcher rubyDispatcher; - RenderDispatcher renderDispatcher; + MainDispatcher mainDispatcher; FileSystem fileSystem; @@ -100,7 +100,7 @@ struct SharedStatePrivate{ : bindingData(0), sdlWindow(threadData->window), rubyDispatcher(), - renderDispatcher(), + mainDispatcher(), fileSystem(threadData->config.allowSymlinks), eThread(*threadData->ethread), rtData(*threadData), @@ -200,7 +200,7 @@ GSATT(void*, bindingData) GSATT(SDL_Window*, sdlWindow) GSATT(Scene*, screen) GSATT(RubyDispatcher&, rubyDispatcher) -GSATT(RenderDispatcher&, renderDispatcher) +GSATT(MainDispatcher&, mainDispatcher) GSATT(FileSystem&, fileSystem) GSATT(EventThread&, eThread) GSATT(RGSSThreadData&, rtData) diff --git a/src/sharedstate.h b/src/sharedstate.h index f4f2605..0ddf7a7 100644 --- a/src/sharedstate.h +++ b/src/sharedstate.h @@ -24,7 +24,7 @@ #include "signals/signal.h" #include "signals/rubydispatcher.h" -#include "signals/renderdispatcher.h" +#include "signals/maindispatcher.h" #define shState SharedState::instance #define glState shState->_glState() @@ -74,7 +74,7 @@ struct SharedState{ // dispatchers, they redirect signals from another thread to their own RubyDispatcher &rubyDispatcher() const; - RenderDispatcher &renderDispatcher() const; + MainDispatcher &mainDispatcher() const; // other shit idk void *bindingData() const; diff --git a/src/signals/renderdispatcher.cpp b/src/signals/maindispatcher.cpp similarity index 66% rename from src/signals/renderdispatcher.cpp rename to src/signals/maindispatcher.cpp index 634a26b..8af3b99 100644 --- a/src/signals/renderdispatcher.cpp +++ b/src/signals/maindispatcher.cpp @@ -1,11 +1,11 @@ -#include "renderdispatcher.h" +#include "maindispatcher.h" -void RenderDispatcher::invoke(std::function fn){ +void MainDispatcher::invoke(std::function fn){ std::lock_guard lock(mutex); queue.push(std::move(fn)); } -void RenderDispatcher::process(){ +void MainDispatcher::process(){ std::queue> local; { diff --git a/src/signals/renderdispatcher.h b/src/signals/maindispatcher.h similarity index 76% rename from src/signals/renderdispatcher.h rename to src/signals/maindispatcher.h index 462f856..38fe3d7 100644 --- a/src/signals/renderdispatcher.h +++ b/src/signals/maindispatcher.h @@ -4,9 +4,9 @@ #include #include -class RenderDispatcher{ +class MainDispatcher{ public: - RenderDispatcher() {}; + MainDispatcher() {}; void invoke(std::function fn); void process(); diff --git a/src/signals/signalconnection.h b/src/signals/signalconnection.h index 756a838..caffdf4 100644 --- a/src/signals/signalconnection.h +++ b/src/signals/signalconnection.h @@ -1,26 +1,35 @@ #pragma once #include +#include "debugwriter.h" class SignalConnection{ public: SignalConnection() = default; + SignalConnection(sigc::connection conn) + : connection(std::move(conn)) + {} void Disconnect() { - connection.disconnect(); + if (&connection != nullptr) + //if (connection.connected()) + connection.disconnect(); + //else + // Debug() << "Double disconnect!"; + else + Debug() << "Couldn't disconnect nullptr connection!"; } bool Connected() const { + if (&connection == nullptr) + Debug() << "nullptr connection!"; + return false; return connection.connected(); } private: - SignalConnection(sigc::connection conn) - : connection(std::move(conn)) - {} - sigc::connection connection; template