diff --git a/PEOPLES.md b/PEOPLES.md
index f1f6c5a..ef97c49 100644
--- a/PEOPLES.md
+++ b/PEOPLES.md
@@ -4,6 +4,7 @@
* "Визя"
* DepressedTWM
* referr
+* блинчек
## Artists
@@ -18,15 +19,16 @@
## Testers and helpers:
* Rubik
* Prime 223432
-
-## Donators
-* Kodu
+* Алула(from Oneshot)
+* Охотник
+* Ouzly
## Telegram moderators
* Creature_of_steel1
* Обси(ENG channel)
* Freskovich
* "Визя"
+* Ouzly
## Matrix moderators
* referr
diff --git a/PORTING.md b/PORTING.md
deleted file mode 100644
index 395b9c4..0000000
--- a/PORTING.md
+++ /dev/null
@@ -1,48 +0,0 @@
-
-## Операционные системы | Operating Systems
-| Платформа
Platform | Завершено
Done % | Состояние
State |
-| :--- | :---: | :--- |
-| Windows | 100% | Играбельно |
-| Linux | 91% | В работе, но уже играбельно
TODO:
\* Fix Wallpaper manager
-| *BSD | 15% | не в работе |
-| GNU/Hurd | 0% | не в работеm не хватает библеотек |
-| Solaris/OpenSolaris | 1% | не в работе |
-| RedoxOS | 0% | Не хватает библеотек |
-| Android | 4% | В работе |
-| PS Vita | 1% | не в работе |
-| PSP | 1% | не в работе |
-| Emspritein(web) | 11% | Нет хватает библеотек
\* Нужно написать порт библеотеки libsigc++2
(А лучше 3 и переписать движок)
\* Проблемы с компиляцией и зависимостями |
-| HaikuOS | 1% | не в работе |
-| DOS | 1% | Не в работе |
-| Ubuntu Touch | 60% | Будет почти готово тогда когда Linux порт будет доведён до ума |
-| Аврора ОС | 0% | не в работе |
-| ChromeOS/ChromiumOS | 0.4% | Неизвестное |
-| MacOS | 10.5% | Неизвестное, но работа ведётся |
-| Kyronix | 10% | В работе сторонней командой разработчиков|
-| PS2 | 40% | В работе сторонним человеком|
-
-## Окружения рабочего стола | Desktop Environments
-| Окружение
Environments | Завершено
Done % |
-| :--- | :---: |
-| X11 standalone window managers | 0% |
-| Wayland standalone window managers | 0% |
-| LXDE | 100% |
-| XFCE | 10% |
-| GNOME | 10% |
-| KDE | 10% |
-| LXQT | 0% |
-| MATE | 100% |
-| Cinnamon | 10% |
-| Budgie | 0% |
-| Deepin | 10% |
-| COSMIC | 0% |
-| Pantheon | 0% |
-| Enlightenment | 0% |
-| Unity | 0% |
-| Sugar Desktop | 0% |
-| ROX Desktop | 0% |
-| Fluxbox | 0% |
-| Trinity | 0% |
-| Fish | 0% |
-| Lumina | 0% |
-| IceWM | 0% |
diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp
index 0a760c5..7b7b5f0 100644
--- a/binding-mri/binding-mri.cpp
+++ b/binding-mri/binding-mri.cpp
@@ -36,6 +36,7 @@
#include "sunshine.h"
#include "modloader.h"
+#include
#include
#include
#include
@@ -158,8 +159,26 @@ RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
RB_METHOD(_kernelCaller);
+
+// TODO: find the reason why Symbol doesn't have some methods
+VALUE rb_symbol_to_s(VALUE self)
+{
+ ID id = SYM2ID(self);
+ const char *name = rb_id2name(id);
+
+ if (!name)
+ return rb_str_new("", 0);
+
+ return rb_utf8_str_new_cstr(name);
+}
+
static void mriBindingInit(){
printf("[mriBindingInit] Loading bindings...\n");
+
+ rb_define_method(rb_cSymbol, "to_s", RUBY_METHOD_FUNC(rb_symbol_to_s), 0);
+ rb_define_method(rb_cSymbol, "name", RUBY_METHOD_FUNC(rb_symbol_to_s), 0);
+ rb_define_method(rb_cSymbol, "id2name", RUBY_METHOD_FUNC(rb_symbol_to_s), 0);
+
tableBindingInit();
etcBindingInit();
fontBindingInit();
@@ -379,7 +398,7 @@ static void runCustomScript(const std::string &filename){
std::string scriptData;
if (!readFileSDL(filename.c_str(), scriptData)){
- crash(Exception::MEOW, "Unable to open %s", filename.c_str());
+ crash(Exception::NoFileError, false, "Unable to open %s", filename.c_str());
return;
}
@@ -400,7 +419,7 @@ static void runRMXPScripts(BacktraceData &btData){
const std::string &scriptPack = conf.game.scripts;
if (!shState->fileSystem().exists(scriptPack.c_str())){
- crash(Exception::MEOW, "Unable to open '%s'", scriptPack.c_str());
+ crash(Exception::IOError, false, "Unable to open '%s'", scriptPack.c_str());
return;
}
@@ -411,12 +430,12 @@ static void runRMXPScripts(BacktraceData &btData){
try{
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
}catch (const Exception &e){
- crash(Exception::MEOW, "Failed to read script data: %s", e.msg.c_str());
+ crash(Exception::IOError, false, "Failed to read script data: %s", e.msg.c_str());
return;
}
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){
- crash(Exception::MEOW, "Failed to read script data");
+ crash(Exception::IOError, false, "Failed to read script data");
return;
}
@@ -454,7 +473,7 @@ static void runRMXPScripts(BacktraceData &btData){
}
if (result != Z_OK){
- crash(Exception::MEOW, "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName));
+ crash(Exception::IOError, false, "Error decoding script %ld: '%s'\n", i, RSTRING_PTR(scriptName));
break;
}
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
@@ -555,8 +574,7 @@ static void showExc(VALUE exc, const BacktraceData &btData){
file.resize(SDL_strlen(file.c_str()));
file = btData.scriptNames.value(file, file);
- crash(Exception::MEOW, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg));
- exit(0);
+ crash(Exception::RUBYError, true, "Script '%s' line %s: %s occured.\n\n%s", file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg));
}
static void mriBindingExecute(){
@@ -565,7 +583,6 @@ static void mriBindingExecute(){
* stdio streams on some platforms (eg. Windows) */
int argc = 0;
char **argv = 0;
- //options_argv3[] = "--jit"
char options_argv1[] = "oneshot", options_argv2[] = "-ev";
char* options_argv[] = {options_argv1, options_argv2, NULL};
ruby_sysinit(&argc, &argv);
diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp
index 581bf97..d816578 100644
--- a/binding-mri/graphics-binding.cpp
+++ b/binding-mri/graphics-binding.cpp
@@ -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
diff --git a/changelogs/0.1.2.txt b/changelogs/0.1.2.txt
index f3d31fa..b4f2371 100644
--- a/changelogs/0.1.2.txt
+++ b/changelogs/0.1.2.txt
@@ -25,3 +25,5 @@ fixed segfault while to fast window size changing
updated cg_blue picture
Deleted useless hooks
fix crash on game exit
+Error handling updated
+added gamepad button icons in settings
diff --git a/oneshot.conf b/oneshot.conf
index 305310e..38bbb04 100644
--- a/oneshot.conf
+++ b/oneshot.conf
@@ -35,10 +35,6 @@ defScreenH=0
# is upscaled
smoothScaling=false
-# Sync screen redraws to the monitor refresh rate
-# (default: enabled)
-vsync=true
-
# Enforce a static frame rate
# (0 = disabled)
fixedFramerate=0
diff --git a/scripts/Data_Gamepads.rb b/scripts/Data_Gamepads.rb
index 4149167..d8918e8 100644
--- a/scripts/Data_Gamepads.rb
+++ b/scripts/Data_Gamepads.rb
@@ -221,7 +221,22 @@ module GamepadMapColors
end
module GamepadIcons
- ICONS_CACHE = []
+ GAMEPADS = [nil,
+ Input::GamepadType::XBOX360,
+ Input::GamepadType::XBOXONE,
+ :series_x,
+ Input::GamepadType::PS3,
+ Input::GamepadType::PS4,
+ Input::GamepadType::PS5,
+ Input::GamepadType::SWITCH_PRO,
+ Input::GamepadType::JOYCON_PAIR,
+ :luna,
+ :ouya,
+ :stadia,
+ :steam_controller,
+ :steam_deck,
+ Input::GamepadType::GAMECUBE
+ ]
ICONS = {
# SDL supported types, can be detected automatically
@@ -244,6 +259,7 @@ module GamepadIcons
},
Input::GamepadType::STANDART => {
:icon => [10, 13],
+ :face_skinnable => true,
:buttons => {
Input::GamepadButton::INVALID => [9, 16],
Input::GamepadButton::SOUTH => [0, 0],
@@ -275,9 +291,9 @@ module GamepadIcons
},
:axes => {
Input::GamepadAxis::INVALID => [[9, 16], [9, 16]],
- Input::GamepadAxis::LEFTX => [[5, 1], [6, 1]],
+ Input::GamepadAxis::LEFTX => [[6, 1], [5, 1]],
Input::GamepadAxis::LEFTY => [[4, 1], [7, 1]],
- Input::GamepadAxis::RIGHTX => [[5, 2], [6, 2]],
+ Input::GamepadAxis::RIGHTX => [[6, 2], [5, 2]],
Input::GamepadAxis::RIGHTY => [[4, 2], [7, 2]],
Input::GamepadAxis::LEFT_TRIGGER => [[6, 4], [9, 16]],
Input::GamepadAxis::RIGHT_TRIGGER => [[7, 4], [9, 16]],
@@ -338,16 +354,6 @@ module GamepadIcons
Input::GamepadButton::MISC1 => [7, 11],
}
},
- Input::GamepadType::PS5 => {
- :extends => Input::GamepadType::PS4,
- :icon => [10, 12],
- :buttons => {
- Input::GamepadButton::BACK => [4, 9],
- Input::GamepadButton::START => [5, 9],
- Input::GamepadButton::TOUCHPAD => [4, 10],
- Input::GamepadButton::MISC1 => [7, 11],
- }
- },
Input::GamepadType::SWITCH_PRO => {
:extends => Input::GamepadType::JOYCON_PAIR,
:icon => [10, 13],
@@ -391,6 +397,7 @@ module GamepadIcons
},
Input::GamepadType::GAMECUBE => {
:extends => Input::GamepadType::STANDART,
+ :face_skinnable => false,
:icon => [8, 11],
:buttons => {
Input::GamepadButton::SOUTH => [8, 10],
@@ -405,9 +412,9 @@ module GamepadIcons
:axes => {
Input::GamepadAxis::LEFT_TRIGGER => [[6, 15], [9, 16]],
Input::GamepadAxis::RIGHT_TRIGGER => [[0, 17], [9, 16]],
- Input::GamepadAxis::LEFTX => [[9, 9], [10, 9]],
+ Input::GamepadAxis::LEFTX => [[10, 9], [9, 9]],
Input::GamepadAxis::LEFTY => [[8, 9], [11, 9]],
- Input::GamepadAxis::RIGHTX => [[9, 8], [10, 8]],
+ Input::GamepadAxis::RIGHTX => [[10, 8], [9, 8]],
Input::GamepadAxis::RIGHTY => [[8, 8], [11, 8]],
}
},
@@ -422,7 +429,7 @@ module GamepadIcons
},
:luna => {
:extends => Input::GamepadType::XBOXONE,
- :icon => [8, 11],
+ :icon => [10, 11],
:buttons => {
Input::GamepadButton::BACK => [7, 13],
Input::GamepadButton::GUIDE => [7, 12],
@@ -455,7 +462,7 @@ module GamepadIcons
Input::GamepadButton::RIGHT_STICK => [3, 17],
},
:axes => {
- Input::GamepadAxis::RIGHTX => [[5, 16], [6, 16]],
+ Input::GamepadAxis::RIGHTX => [[6, 16], [5, 16]],
Input::GamepadAxis::RIGHTY => [[4, 16], [7, 16]],
}
},
@@ -477,7 +484,7 @@ module GamepadIcons
},
:stadia => {
:extends => Input::GamepadType::XBOXONE,
- :icon => [8, 17],
+ :icon => [10, 13],
:buttons => {
Input::GamepadButton::BACK => [5, 8],
Input::GamepadButton::GUIDE => [8, 17],
@@ -492,26 +499,179 @@ module GamepadIcons
}
GUIDS = {
-
+ "030000006f0e00001301000000000000" => :series_x,
+ "030000006f0e00001304000000000000" => :series_x,
+ "030000006f0e00001302000000000000" => :series_x,
+ "030000006f0e00003901000000000000" => :series_x,
+ "030000006f0e00001413000000000000" => :series_x,
+ "03000000ab1200000103000000000000" => :series_x,
+ "03000000ad1b000000f9000000000000" => :series_x,
+ "030000005e040000130b000000000000" => :series_x,
+ "03000000373500000411000023000000" => :series_x,
+ "030000005e040000050b000003090000" => :series_x,
+ "030000005e040000130b000001050000" => :series_x,
+ "030000005e040000130b000013050000" => :series_x,
+ "030000005e040000130b000015050000" => :series_x,
+ "030000005e040000130b000007050000" => :series_x,
+ "030000005e040000130b000017050000" => :series_x,
+ "030000005e040000130b000022050000" => :series_x,
+ "030000005e040000220b000017050000" => :series_x,
+ "030000005e040000220b000021050000" => :series_x,
+ "03000000c82d00000a20000000020000" => :series_x,
+ "03000000c82d00000020000000000000" => :series_x,
+ "06000000c82d00000020000006010000" => :series_x,
+ "030000005e040000120b00000b050000" => :series_x,
+ "030000005e040000120b000016050000" => :series_x,
+ "030000005e040000120b000017050000" => :series_x,
+ "060000005e040000120b000001050000" => :series_x,
+ "030000006f0e0000d702000006640000" => :series_x,
+ "030000006f0e0000d802000006640000" => :series_x,
+ "030000006f0e0000ef02000007640000" => :series_x,
+ "03000000d62000000540000001010000" => :series_x,
+ "03000000d62000000520000050010000" => :series_x,
+ "03000000d62000000b20000001010000" => :series_x,
+ "03000000d62000000f20000001010000" => :series_x,
+ "03000000d62000006520000002010000" => :series_x,
+ "030000004b2900000430000011000000" => :series_x,
+ "030000005e040000120b000001050000" => :series_x,
+ "030000005e040000120b000005050000" => :series_x,
+ "030000005e040000120b000007050000" => :series_x,
+ "030000005e040000120b000009050000" => :series_x,
+ "030000005e040000120b00000d050000" => :series_x,
+ "030000005e040000120b00000f050000" => :series_x,
+ "030000005e040000120b000011050000" => :series_x,
+ "030000005e040000120b000014050000" => :series_x,
+ "030000005e040000120b000015050000" => :series_x,
+ "030000005e040000130b000005050000" => :series_x,
+ "050000005e040000130b000001050000" => :series_x,
+ "050000005e040000130b000005050000" => :series_x,
+ "050000005e040000130b000007050000" => :series_x,
+ "050000005e040000130b000009050000" => :series_x,
+ "050000005e040000130b000011050000" => :series_x,
+ "050000005e040000130b000013050000" => :series_x,
+ "050000005e040000130b000015050000" => :series_x,
+ "050000005e040000130b000017050000" => :series_x,
+ "060000005e040000120b000007050000" => :series_x,
+ "060000005e040000120b00000b050000" => :series_x,
+ "060000005e040000120b00000d050000" => :series_x,
+ "060000005e040000120b00000f050000" => :series_x,
+ "050000005e040000130b000022050000" => :series_x,
+ "060000005e040000120b000011050000" => :series_x,
+ "32386235353630393033393135613831" => :series_x,
+ "050000005e040000120b000000783f00" => :series_x,
+ "050000005e040000120b000000783f80" => :series_x,
+ "050000005e040000130b0000ffff3f00" => :series_x,
+ "65633038363832353634653836396239" => :series_x,
+ "050000005e040000130b0000df870001" => :series_x,
+ "050000005e040000130b0000ff870001" => :series_x,
+ "0300fa675e040000ff02000000007801" => :series_x, # this is my gamepad, but for some reason it is not in the gamecontrollerdb.txt
+ "03000000491900001904000000000000" => :luna,
+ "03000000710100001904000000000000" => :luna,
+ "03000000491900001904000001010000" => :luna,
+ "03000000710100001904000000010000" => :luna,
+ "03000000491900001904000011010000" => :luna,
+ "05000000710100001904000000010000" => :luna,
+ "32333634613735616163326165323731" => :luna,
+ "416d617a6f6e2047616d6520436f6e74" => :luna,
+ "4c756e612047616d6570616400000000" => :luna,
+ "03000000362800000100000000000000" => :ouya,
+ "05000000362800000100000002010000" => :ouya,
+ "05000000362800000100000003010000" => :ouya,
+ "05000000362800000100000004010000" => :ouya,
+ "39383335313438623439373538343266" => :ouya,
+ "4f5559412047616d6520436f6e74726f" => :ouya,
+ "03000000de2800000112000001000000" => :steam_controller,
+ "03000000de2800000112000011010000" => :steam_controller,
+ "03000000de2800000211000001000000" => :steam_controller,
+ "03000000de2800000211000011010000" => :steam_controller,
+ "03000000de2800004211000001000000" => :steam_controller,
+ "03000000de2800004211000011010000" => :steam_controller,
+ "03000000de280000fc11000001000000" => :steam_controller,
+ "05000000de2800000212000001000000" => :steam_controller,
+ "05000000de2800000511000001000000" => :steam_controller,
+ "05000000de2800000611000001000000" => :steam_controller,
+ "30623739343039643830333266346439" => :steam_controller,
+ "31643365666432386133346639383937" => :steam_controller,
+ "03000000de2800000512000010010000" => :steam_deck,
+ "03000000de2800000512000011010000" => :steam_deck,
+ "03000000d11800000094000000000000" => :stadia,
+ "03000000d11800000094000000010000" => :stadia,
+ "03000000d11800000094000011010000" => :stadia,
+ "05000000d11800000094000000010000" => :stadia,
+ "35383633353935396534393230616564" => :stadia,
+ "476f6f676c65204c4c43205374616469" => :stadia,
+ "5374616469614e3848532d6532633400" => :stadia,
}
class << self
- def button(id, skinned = true, gamepad_type = nil)
- current_gamepad = gamepad_type
- if !ICONS.has_key?(gamepad_type)
- current_gamepad = Input::GamepadType.current_type
- if !ICONS.has_key?(current_gamepad)
- current_gamepad = Input::GamepadType::UNKNOWN
+ def icon(gamepad_type = nil)
+ current_gamepad = get_gamepad_type(gamepad_type)
+
+ debug_string = ""
+ iterations = 0
+
+ result = nil
+ while !result
+ if !ICONS[current_gamepad].has_key?(:icon)
+ current_gamepad = ICONS[current_gamepad][:extends]
+ debug_string << "gamepad " << current_gamepad << "\n"
+ iterations += 1
+ if iterations > 10
+ puts debug_string
+ result = [8, 16]
+ end
+ next
end
+ result = ICONS[current_gamepad][:icon].clone
+ current_gamepad = ICONS[current_gamepad][:extends]
end
+ result
+ end
+
+ def face_skinnable(gamepad_type = nil)
+ current_gamepad = get_gamepad_type(gamepad_type)
+
+ debug_string = ""
+ iterations = 0
+
+ result = nil
+ while result == nil
+ if !ICONS[current_gamepad].has_key?(:face_skinnable)
+ current_gamepad = ICONS[current_gamepad][:extends]
+ debug_string << "gamepad " << current_gamepad << "\n"
+ iterations += 1
+ if iterations > 10
+ puts debug_string
+ result = false
+ end
+ next
+ end
+ result = ICONS[current_gamepad][:face_skinnable]
+ current_gamepad = ICONS[current_gamepad][:extends]
+ end
+ result
+ end
+
+ def button(id, skinned = true, gamepad_type = nil)
+ current_gamepad = get_gamepad_type(gamepad_type)
+
+ debug_string = ""
+ iterations = 0
result = nil
while !result
if !ICONS[current_gamepad].has_key?(:buttons)
current_gamepad = ICONS[current_gamepad][:extends]
+ debug_string << current_gamepad << "\n"
+ iterations += 1
+ if iterations > 10
+ puts debug_string
+ result = [8, 16]
+ end
next
end
result = ICONS[current_gamepad][:buttons][id].clone
+ current_gamepad = ICONS[current_gamepad][:extends]
end
if skinned
if id == Input::GamepadButton::SOUTH ||
@@ -525,23 +685,42 @@ module GamepadIcons
end
def axis(id, dir, gamepad_type = nil)
- current_gamepad = gamepad_type
- if !ICONS.has_key?(gamepad_type)
- current_gamepad = Input::GamepadType.current_type
- if !ICONS.has_key?(current_gamepad)
- current_gamepad = Input::GamepadType::UNKNOWN
- end
- end
+ current_gamepad = get_gamepad_type(gamepad_type)
+
+ debug_string = ""
+ iterations = 0
result = nil
while !result
if !ICONS[current_gamepad].has_key?(:axes)
current_gamepad = ICONS[current_gamepad][:extends]
+ debug_string << "gamepad " << current_gamepad << "\n"
+ iterations += 1
+ if iterations > 10
+ puts debug_string
+ result = [8, 16]
+ end
next
end
- result = ICONS[current_gamepad][:axes][id][1 - dir].clone
+ axis = ICONS[current_gamepad][:axes][id]
+ result = axis[1 - dir].clone if axis
+ current_gamepad = ICONS[current_gamepad][:extends]
end
result
end
+
+ def get_gamepad_type(gamepad_override = nil)
+ current_gamepad = gamepad_override || GamepadIcons::GAMEPADS[Settings[:gamepad_type]]
+ if !ICONS.has_key?(current_gamepad)
+ current_gamepad = GUIDS[Input::GamepadType.current_guid]
+ if !ICONS.has_key?(current_gamepad)
+ current_gamepad = Input::GamepadType.current_type
+ if !ICONS.has_key?(current_gamepad)
+ current_gamepad = Input::GamepadType::UNKNOWN
+ end
+ end
+ end
+ current_gamepad
+ end
end
end
\ No newline at end of file
diff --git a/scripts/Data_Settings.rb b/scripts/Data_Settings.rb
index d04a72b..42f8f79 100644
--- a/scripts/Data_Settings.rb
+++ b/scripts/Data_Settings.rb
@@ -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,
@@ -294,25 +301,42 @@ class Window_Settings
{ :type => :sep, :name => "Gamepad" },
{
:type => :custom,
- :name => "Face buttons style",
- :parameter => :gamepad_face_style,
+ :name => "Your gamepad type",
+ :parameter => :gamepad_type,
:default => 0,
:callbacks => {
:init => proc { |super_proc|
- @max_value = 5
+ @max_value = GamepadIcons::GAMEPADS.length
+ @texts = [
+ "Auto",
+ "XBOX 360",
+ "XBOX One",
+ "XBOX Series X",
+ "PS 3",
+ "PS 4",
+ "PS 5",
+ "Nintendo Switch Pro",
+ "Nintendo Joycons",
+ "Amazon Luna",
+ "OUYA",
+ "Google Stadia",
+ "Steam Controller",
+ "Steam Deck",
+ "Nintendo GAMECUBE"
+ ]
super_proc.call
},
:get_display_value => proc { |super_proc|
- "" # meow >w<
+ ""
},
:redraw => proc { |super_proc|
super_proc.call
- x, y = GamepadIcons.button(Input::GamepadButton::SOUTH, false)
- y += self.value * ICON_SIZE
+ x, y = GamepadIcons.icon()
- @sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 4 * 2, (PARAMETER_HEIGHT - ICON_SIZE * 2) / 2, ICON_SIZE * 4 * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(x, y, ICON_SIZE * 4, ICON_SIZE))
+ @sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 2, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(x * ICON_SIZE, y * ICON_SIZE, ICON_SIZE, ICON_SIZE))
+ @sprite.bitmap.draw_text(@sprite.bitmap.width - @value_width - ICON_SIZE * 2 - 8, 0, @value_width, @sprite.bitmap.height, tr(@texts[self.value]), 2)
},
:value_set => proc { |super_proc, value|
if (value != self.value)
@@ -332,9 +356,62 @@ class Window_Settings
}
}
},
+ {
+ :type => :custom,
+ :name => "Face buttons style",
+ :parameter => :gamepad_face_style,
+ :default => 0,
+ :callbacks => {
+ :init => proc { |super_proc|
+ @max_value = 5
+
+ super_proc.call
+ },
+ :get_display_value => proc { |super_proc|
+ "" # meow >w<
+ },
+ :redraw => proc { |super_proc|
+ @disabled = !GamepadIcons.face_skinnable
+
+ super_proc.call
+
+ sx, sy = GamepadIcons.button(Input::GamepadButton::SOUTH, false)
+ wx, wy = GamepadIcons.button(Input::GamepadButton::WEST, false)
+ nx, ny = GamepadIcons.button(Input::GamepadButton::NORTH, false)
+ ex, ey = GamepadIcons.button(Input::GamepadButton::EAST, false)
+ if GamepadIcons.face_skinnable
+ sy += self.value
+ wy += self.value
+ ny += self.value
+ ey += self.value
+ end
+
+ @sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 8, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(sx * ICON_SIZE, sy * ICON_SIZE, ICON_SIZE, ICON_SIZE))
+ @sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 6, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(wx * ICON_SIZE, wy * ICON_SIZE, ICON_SIZE, ICON_SIZE))
+ @sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 4, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(nx * ICON_SIZE, ny * ICON_SIZE, ICON_SIZE, ICON_SIZE))
+ @sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 2, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(ex * ICON_SIZE, ey * ICON_SIZE, ICON_SIZE, ICON_SIZE))
+ },
+ :value_set => proc { |super_proc, value|
+ if (value != self.value)
+ Audio.se_play(PARAMETER_CHANGE_AUDIO, 70, (value.to_f / @max_value.to_f * 50.0).to_i + 75)
+ end
+ super_proc.call(value)
+ },
+ :value_left => proc { |super_proc|
+ next if @disabled
+ self.value = (self.value - 1) % @max_value
+ @settings_content.redraw_all
+ },
+ :value_right => proc { |super_proc|
+ next if @disabled
+ self.value = (self.value + 1) % @max_value
+ @settings_content.redraw_all
+ }
+ }
+ },
{
:type => :bool,
- :name => "Control LED lighting on gamepads",
+ :name => "Control LED lighting",
:parameter => :gamepad_led
},
{ :type => :sep, :name => "Walk" },
@@ -447,45 +524,53 @@ 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 },
{
: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],
}
],
"Mods" => [
@@ -503,3 +588,4 @@ class Window_Settings
DATA["Mods"] << setting
end
end
+
diff --git a/scripts/Main.rb b/scripts/Main.rb
index 04df541..d35a355 100644
--- a/scripts/Main.rb
+++ b/scripts/Main.rb
@@ -22,7 +22,6 @@ begin
Font.default_size = 20
#debug shit
Input.set_led(255, 150, 30)
-
# Load persistent data
Persistent.load
diff --git a/scripts/Settings_Classes.rb b/scripts/Settings_Classes.rb
index 6fe2ea5..f4a6d88 100644
--- a/scripts/Settings_Classes.rb
+++ b/scripts/Settings_Classes.rb
@@ -730,8 +730,9 @@ class Window_Settings
def redraw()
redraw_icon
offset = !!@icon_position ? ICON_SIZE * 2 + 8 : 0
- if (@parameter)
+ if @parameter && @key_binds != Settings[@parameter]
@key_binds = Settings[@parameter]
+ apply
end
@sprite.bitmap.clear
@@ -747,7 +748,7 @@ class Window_Settings
offset = (@selected && i == @selection ? SELECTED_KEYS_MARGIN : 4)
parameter_x = @sprite.bitmap.width - PARAMETER_KEY_WIDTH * (4 - i)
key_bind = @key_binds[i]
- if key_bind && key_bind.type > KeyBind::Type::Key && key_bind.type < KeyBind::Type::JButton
+ if !(@waiting_for_key && i == @selection) && key_bind && key_bind.type > KeyBind::Type::Key && key_bind.type < KeyBind::Type::JButton
icon_x, icon_y = case key_bind.type
when KeyBind::Type::CButton
GamepadIcons.button(key_bind.button)
@@ -821,12 +822,12 @@ class Window_Settings
@waiting_for_key = @settings_content.waiting_for_key = false
apply
redraw
- elsif c_button
+ elsif c_button && (!Input.press?(Input::ACTION) || @accept_action)
Settings[@parameter][@selection] = KeyBind.cbutton(c_button)
@waiting_for_key = @settings_content.waiting_for_key = false
apply
redraw
- elsif c_axis
+ elsif c_axis && (!Input.press?(Input::ACTION) || @accept_action)
Settings[@parameter][@selection] = KeyBind.caxis(c_axis, Input::c_axis_pressure(c_axis) > 0 ? KeyBind::Positive : KeyBind::Negative)
@waiting_for_key = @settings_content.waiting_for_key = false
apply
diff --git a/scripts/Settings_Setters.rb b/scripts/Settings_Setters.rb
index 0cfd10e..ac276e4 100644
--- a/scripts/Settings_Setters.rb
+++ b/scripts/Settings_Setters.rb
@@ -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")
diff --git a/shader/dynamicLight.frag b/shader/dynamicLight.frag
index cbb94a1..8979628 100644
--- a/shader/dynamicLight.frag
+++ b/shader/dynamicLight.frag
@@ -4,7 +4,7 @@ uniform int lightSourcesCount;
uniform float ambientLight;
uniform sampler2D texture;
-uniform sampler2D wallMapTexture;
+//uniform sampler2D wallMapTexture;
uniform vec2 wallMapResolution;
@@ -24,8 +24,8 @@ float distance(vec2 a, vec2 b){
void main(){
vec2 screenPoint = v_texCoord / texSizeInv;
- vec2 mapPoint = cameraPosition + screenPoint;
- vec2 wallmapUV = mapPoint / tileSize / wallMapResolution;
+ //vec2 mapPoint = cameraPosition + screenPoint;
+ //vec2 wallmapUV = mapPoint / tileSize / wallMapResolution;
vec3 light = vec3(0, 0, 0);
diff --git a/src/al-util.h b/src/al-util.h
index 8d8ffb2..aa2a2fb 100644
--- a/src/al-util.h
+++ b/src/al-util.h
@@ -182,7 +182,7 @@ inline uint8_t formatSampleSize(int sdlFormat){
case SDL_AUDIO_S16BE :
return 2;
default :
- crash(Exception::MEOW, "Unhandled sample format");
+ crash(Exception::SDLError, true, "Unhandled sample format");
}
return 0;
@@ -201,7 +201,7 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount){
case 2 : return AL_FORMAT_STEREO16;
}
default :
- crash(Exception::MEOW, "Unhandled sample size / channel count");
+ crash(Exception::SDLError, true, "Unhandled sample size / channel count");
}
return 0;
diff --git a/src/alstream.cpp b/src/alstream.cpp
index 5cc77de..7cd9b53 100644
--- a/src/alstream.cpp
+++ b/src/alstream.cpp
@@ -223,9 +223,8 @@ void ALStream::openSource(const std::string &filename){
shState->fileSystem().openRead(handler, filename.c_str());
source = handler.source;
needsRewind.clear();
-
if (!source)
- crash(Exception::MEOW, "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str());
+ crash(Exception::SDLError, true, "Unable to decode audio stream: %s: %s", filename.c_str(), handler.errorMsg.c_str());
}
void ALStream::stopStream(){
diff --git a/src/bitmap.cpp b/src/bitmap.cpp
index 4c335bf..fa5aad7 100644
--- a/src/bitmap.cpp
+++ b/src/bitmap.cpp
@@ -48,7 +48,7 @@
#define GUARD_MEGA \
{ \
if (p->megaSurface) \
- crash(Exception::MKXPError, "Operation not supported for mega surfaces"); \
+ crash(Exception::MKXPError, true, "Operation not supported for mega surfaces"); \
}
#define OUTLINE_SIZE 1
@@ -221,12 +221,11 @@ struct BitmapOpenHandler : FileSystem::OpenHandler{
Bitmap::Bitmap(const char *filename){
BitmapOpenHandler handler;
- char msg[1024];
shState->fileSystem().openRead(handler, filename);
SDL_Surface *imgSurf = handler.surf;
if (!imgSurf)
- crash(Exception::SDLError, "Error loading image '%s': %s", filename, SDL_GetError());
+ crash(Exception::SDLError, true, "Error loading image '%s': %s", filename, SDL_GetError());
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
@@ -262,7 +261,7 @@ Bitmap::Bitmap(const char *filename){
Bitmap::Bitmap(int width, int height){
if (width <= 0 || height <= 0)
- crash(Exception::RGSSError, "failed to create bitmap");
+ crash(Exception::RGSSError, true, "failed to create bitmap");
TEXFBO tex = shState->texPool().request(width, height);
diff --git a/src/config.cpp b/src/config.cpp
index 91ad7db..63897fb 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -74,7 +74,6 @@ void Config::read(int argc, char *argv[]){
PO_DESC(fixedAspectRatio, bool, true) \
/*PO_DESC(AspectPreset, int, 1)*/ \
PO_DESC(smoothScaling, bool, false) \
- PO_DESC(vsync, bool, true) \
PO_DESC(defScreenW, int, 0) \
PO_DESC(defScreenH, int, 0) \
PO_DESC(windowTitle, std::string, "") \
diff --git a/src/config.h b/src/config.h
index 515744e..e495791 100644
--- a/src/config.h
+++ b/src/config.h
@@ -35,7 +35,6 @@ struct Config{
bool resolutionOverridden;
bool Windows_AllocConsole;
bool smoothScaling;
- bool vsync;
bool pancakes;
int defScreenW;
int defScreenH;
diff --git a/src/etc.cpp b/src/etc.cpp
index 127457b..bf1341a 100644
--- a/src/etc.cpp
+++ b/src/etc.cpp
@@ -100,7 +100,7 @@ void Color::serialize(char *buffer) const{
Color *Color::deserialize(const char *data, int len){
if (len != 32)
- crash(Exception::ArgumentError, "Color: Serialized data invalid");
+ crash(Exception::ArgumentError, true, "Color: Serialized data invalid");
Color *c = new Color();
@@ -219,7 +219,7 @@ void Tone::serialize(char *buffer) const{
Tone *Tone::deserialize(const char *data, int len){
if (len != 32)
- crash(Exception::ArgumentError, "Tone: Serialized data invalid");
+ crash(Exception::ArgumentError, true, "Tone: Serialized data invalid");
Tone *t = new Tone();
@@ -350,7 +350,7 @@ void Rect::serialize(char *buffer) const{
Rect *Rect::deserialize(const char *data, int len){
if (len != 16)
- crash(Exception::ArgumentError, "Rect: Serialized data invalid");
+ crash(Exception::ArgumentError, true, "Rect: Serialized data invalid");
Rect *r = new Rect();
diff --git a/src/eventthread.cpp b/src/eventthread.cpp
index 9d1eab8..d170927 100644
--- a/src/eventthread.cpp
+++ b/src/eventthread.cpp
@@ -33,6 +33,7 @@
#include
#include
#include
+#include
#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(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;
diff --git a/src/eventthread.h b/src/eventthread.h
index 33cc36e..ae3d54c 100644
--- a/src/eventthread.h
+++ b/src/eventthread.h
@@ -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;
diff --git a/src/exception.h b/src/exception.h
index 982d864..d932cbe 100644
--- a/src/exception.h
+++ b/src/exception.h
@@ -28,6 +28,7 @@
struct Exception{
enum Type{
RGSSError,
+ RUBYError,
NoFileError,
IOError,
@@ -42,9 +43,6 @@ struct Exception{
//modloader
ModLoaderError,
-
- // For crash()
- MEOW
};
Type type;
diff --git a/src/font.cpp b/src/font.cpp
index 8cc1f4b..d0e9346 100644
--- a/src/font.cpp
+++ b/src/font.cpp
@@ -127,22 +127,20 @@ TTF_Font *SharedFontState::getFont(std::string family, unsigned int size){
SDL_IOStream *ops;
if (family.empty()){
- crash(Exception::RGSSError, "font does not exist");
+ crash(Exception::RGSSError, true, "font does not exist");
}else{
/* Use 'other' path as alternative in case
* we have no 'regular' styled font asset */
const char *path = !req.regular.empty()
? req.regular.c_str() : req.other.c_str();
- //ops = SDL_OpenIO();
- // SDL_IOStream* ops;
shState->fileSystem().openReadRaw(ops, path);
}
font = TTF_OpenFontIO(ops, 1, size);
if (!font){
- crash(Exception::SDLError, "%s", SDL_GetError());
+ crash(Exception::SDLError, true, "%s", SDL_GetError());
}
p->pool.insert(key, font);
@@ -303,7 +301,7 @@ void Font::setSize(int value){
/* Catch illegal values (according to RMXP) */
if (value < 6 || value > 96)
- crash(Exception::ArgumentError, "%s", "bad value for size");
+ crash(Exception::ArgumentError, true, "%s", "bad value for size");
p->size = value;
p->sdlFont = 0;
diff --git a/src/gl-fun.cpp b/src/gl-fun.cpp
index 20b5835..9c0f602 100644
--- a/src/gl-fun.cpp
+++ b/src/gl-fun.cpp
@@ -91,7 +91,7 @@ void initGLFunctions(){
int glMajor = *ver - '0';
if (glMajor < 2)
- crash(Exception::MKXPError, "At least OpenGL (ES) 2.0 is required");
+ crash(Exception::MKXPError, false, "At least OpenGL (ES) 2.0 is required");
if (gles){
GL_ES_FUN;
@@ -126,7 +126,7 @@ void initGLFunctions(){
}
}
else{
- crash(Exception::MKXPError, "No FBO support available");
+ crash(Exception::MKXPError, false, "No FBO support available");
}
/* VAO entrypoints */
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 473f7d3..4508175 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -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;
}
diff --git a/src/graphics.h b/src/graphics.h
index 2e18885..aa99402 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -58,6 +58,8 @@ public:
void reset();
+ void setVsync(int value);
+
/* Non-standard extension */
DECL_ATTR( Fullscreen, bool )
DECL_ATTR( ShowCursor, bool )
diff --git a/src/main.cpp b/src/main.cpp
index e31d06f..b7f7036 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -99,7 +99,7 @@ int rgssThreadFun(void *userdata){
glCtx = SDL_GL_CreateContext(win);
if (!glCtx){
- crash(Exception::MEOW, "Error creating context: %s", SDL_GetError());
+ crash(Exception::SDLError, false, "Error creating context: %s", SDL_GetError());
rgssThreadError(threadData, std::string(msg));
return 0;
}
@@ -108,7 +108,7 @@ int rgssThreadFun(void *userdata){
initGLFunctions();
}
catch (const Exception &exc){
- crash(Exception::MEOW, exc.msg.c_str());
+ crash(Exception::RGSSError, false, exc.msg.c_str());
rgssThreadError(threadData, exc.msg);
SDL_GL_DestroyContext(glCtx);
return 0;
@@ -125,9 +125,6 @@ int rgssThreadFun(void *userdata){
Debug() << "[main] GL Renderer :" << glGetStringInt(GL_RENDERER);
Debug() << "[main] GL Version :" << glGetStringInt(GL_VERSION);
Debug() << "[main] GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION);
-
- bool vsync = conf.vsync || conf.syncToRefreshrate;
- SDL_GL_SetSwapInterval(vsync ? 1 : 0);
#ifndef NDEBUG
GLDebugLogger dLogger;
#endif
@@ -136,7 +133,6 @@ int rgssThreadFun(void *userdata){
ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
if (!alcCtx){
- crash(Exception::MEOW, "Error creating OpenAL context");
rgssThreadError(threadData, "Error creating OpenAL context");
SDL_GL_DestroyContext(glCtx);
return 0;
@@ -147,11 +143,9 @@ int rgssThreadFun(void *userdata){
try{
SharedState::initInstance(threadData);
}catch (const Exception &exc){
- crash(Exception::MEOW, exc.msg.c_str());
rgssThreadError(threadData, exc.msg);
alcDestroyContext(alcCtx);
SDL_GL_DestroyContext(glCtx);
-
return 0;
}
@@ -165,7 +159,6 @@ int rgssThreadFun(void *userdata){
alcDestroyContext(alcCtx);
SDL_GL_DestroyContext(glCtx);
-
return 0;
}
@@ -224,13 +217,11 @@ int main(int argc, char *argv[]){
#if dos
__djgpp_nearptr_enable();
#endif
-
SecurityManagerInit();
startTime = boost::chrono::high_resolution_clock::now();
loadLanguageMetadata(); //there will be a segfault on fclose if I don't move it here
-
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
- SDL_SetAppMetadata("Oneshot: Sunshine", "0.1.1", "com.catwindowteam.sunshine");
+ SDL_SetAppMetadata("Oneshot: Sunshine", "0.1.2", "com.catwindowteam.sunshine");
//X11 work on *BSD,Solaris too!
#if unix_like
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
@@ -250,19 +241,19 @@ int main(int argc, char *argv[]){
#endif
/* initialize SDL first */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == false){
- crash(Exception::MEOW, "Error initializing SDL: %s", SDL_GetError());
+ crash(Exception::SDLError, false, "Error initializing SDL: %s", SDL_GetError());
return 0;
}
#ifdef STEAM
if (!STEAMSHIM_init()){
- crash(Exception::MEOW, "Could not initialize Steamworks API");
+ crash(Exception::SDLError, false, "Could not initialize Steamworks API");
return 0;
}
#endif
if (!EventThread::allocUserEvents()){
- crash(Exception::MEOW, "Error allocating SDL user events");
+ crash(Exception::SDLError, false, "Error allocating SDL user events");
return 0;
}
@@ -293,7 +284,7 @@ int main(int argc, char *argv[]){
if (!conf.gameFolder.empty()){
if (chdir(conf.gameFolder.c_str()) != 0){
- crash(Exception::MEOW, "Unable to switch into gameFolder %s", conf.gameFolder.c_str());
+ crash(Exception::SDLError, false, "Unable to switch into gameFolder %s", conf.gameFolder.c_str());
return 0;
}
}
@@ -306,12 +297,12 @@ int main(int argc, char *argv[]){
conf.windowTitle = conf.game.title;
if (TTF_Init() == false){
- crash(Exception::MEOW, "Error initializing SDL_ttf: %s", SDL_GetError());
+ crash(Exception::SDLError, false,"Error initializing SDL_ttf: %s", SDL_GetError());
SDL_Quit();
}
if (Sound_Init() == false){
- crash(Exception::MEOW, "Error initializing SDL_sound: %s", Sound_GetError());
+ crash(Exception::SDLError, false,"Error initializing SDL_sound: %s", Sound_GetError());
TTF_Quit();
SDL_Quit();
@@ -326,7 +317,7 @@ int main(int argc, char *argv[]){
SDL_SetWindowFullscreen(win, true);
if (!win){
- crash(Exception::MEOW, "Error creating window: %s", SDL_GetError());
+ crash(Exception::SDLError, false,"Error creating window: %s", SDL_GetError());
return 0;
}
@@ -342,7 +333,7 @@ int main(int argc, char *argv[]){
if (!alcDev){
SDL_DestroyWindow(win);
- crash(Exception::MEOW, "Error opening OpenAL device");
+ crash(Exception::SDLError, false, "Error opening OpenAL device");
TTF_Quit();
SDL_Quit();
return 0;
@@ -394,7 +385,7 @@ int main(int argc, char *argv[]){
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and Sunshine will now force quit", win);
if (!rtData.rgssErrorMsg.empty())
- crash(Exception::MEOW, rtData.rgssErrorMsg.c_str());
+ crash(Exception::RGSSError, false, rtData.rgssErrorMsg.c_str());
/* Clean up any remainin events */
eventThread.cleanup();
@@ -409,7 +400,7 @@ int main(int argc, char *argv[]){
Sound_Quit();
TTF_Quit();
- SDL_Quit(); // i got "Thread 1 received signal ?, Unknown signal" here on windows after closing game
+ SDL_Quit();
#ifdef STEAM
STEAMSHIM_deinit();
diff --git a/src/meow.cpp b/src/meow.cpp
index 98943c1..f6eea92 100644
--- a/src/meow.cpp
+++ b/src/meow.cpp
@@ -13,30 +13,39 @@
#include "gl-debug.h"
#include "gl-fun.h"
#include "debugwriter.h"
+#include "define.h"
#include
#include
#include
#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#undef vsnprintf
+#undef snprintf
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
#endif
#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include "sunshine.h"
-#ifdef __LINUX__
+#ifdef unix_like
#include
#include "xdg-user-dir-lookup.h"
-#elif __ANDROID__
+#elif android
#include
#include
-#elif __EMSCRIPTEN__
+#elif web
#include
+#elif dos
+ #include
#endif
SDL_MessageBoxButtonData buttons[] = {
@@ -48,8 +57,10 @@ static inline const char* glGetStringInt(GLenum name){
return (const char*) gl.GetString(name);
}
-void crash(Exception::Type t, const char *fmt, ...){
- char msg[1024];
+void crash(Exception::Type t, bool do_crash, const char *fmt, ...){
+ static char msg[1024];
+ static const char* reason = nullptr;
+ static const char* solution = nullptr;
va_list args;
va_start(args, fmt);
va_list args_copy;
@@ -59,7 +70,18 @@ void crash(Exception::Type t, const char *fmt, ...){
char *buf = (char*)SDL_malloc((size_t)len + 1);
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
va_end(args);
- SDL_snprintf(msg, sizeof msg, "Error occured! Error message: %s\n\n Want to create a crash SDL_log? You can share the crash SDL_log with the developers and help resolve the issue.", buf);
+ if(t == Exception::ModLoaderError){
+ reason = "Broken mod";
+ solution = "Fix mode manualy or ask developer to fix it or delete mod";
+ }else if(t == Exception::NoFileError){
+ reason = "Broken installation";
+ solution = "Try reinstall game";
+ }else{
+ reason = "Unknown";
+ solution = "Unknown";
+ }
+
+ SDL_snprintf(msg, sizeof msg, "Error occured! Error message: %s\n\nWant to create a crash log? You can share the crash log with the developers and help resolve the issue.\n\nPossible reason:%s\n\nPossible solution: %s", buf, reason, solution);
SDL_MessageBoxData messageboxdata = {
.flags = SDL_MESSAGEBOX_ERROR,
.window = NULL,
@@ -85,21 +107,6 @@ void crash(Exception::Type t, const char *fmt, ...){
o << "REASON: " << buf << std::endl;
o << "[BOOST stacktrace()]" << std::endl;
o << boost::stacktrace::stacktrace() << std::endl;
- o << "[OpenGL]" << std::endl;
- if (gl.GetString){
- try{
- o << "GL Vendor: " << glGetStringInt(GL_VENDOR) << std::endl;
- o << "GL Renderer: " << glGetStringInt(GL_RENDERER) << std::endl;
- o << "GL Version: " << glGetStringInt(GL_VERSION) << std::endl;
- o << "GLSL Version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl;
- o << "Shading language version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl;
- o << "GL Extensions: " << glGetStringInt(GL_EXTENSIONS) << std::endl;
- }catch(const std::exception& e){
- o << "Crashed before OpenGL initialization: " << e.what() << std::endl;
- }
- }else{
- o << "OpenGL not initialized yet" << std::endl;
- }
o << "[Versions of libs]" << std::endl;
const int sdlcompiled = SDL_VERSION;
const int sdllinked = SDL_GetVersion();
@@ -119,10 +126,11 @@ void crash(Exception::Type t, const char *fmt, ...){
}catch(const std::exception& e){
o << "Detected OS: " << e.what() << std::endl;
}
- if(!SDL_getenv("XDG_CURRENT_DESKTOP") == NULL){
- o << "Desktop enviroment(XDG_CURRENT_DESKTOP): " << SDL_getenv("XDG_CURRENT_DESKTOP") << std::endl;
- }
- #ifdef __ANDROID__
+ #ifdef unix_like
+ if(SDL_getenv("XDG_CURRENT_DESKTOP") != nullptr){
+ o << "Desktop enviroment(XDG_CURRENT_DESKTOP): " << SDL_getenv("XDG_CURRENT_DESKTOP") << std::endl;
+ }
+ #elif android
o << "Android API version: " << android_get_device_api_level() << std::endl;
o << "External storage State: " << SDL_GetAndroidExternalStorageState() << std::endl;
o << "Internal storage path: " << SDL_GetAndroidInternalStoragePath() << std::endl;
@@ -136,32 +144,54 @@ void crash(Exception::Type t, const char *fmt, ...){
o << "Is TV? " << SDL_IsTV() << std::endl;
o << "Is Ubuntu Touch? " << SDL_IsUbuntuTouch() << std::endl;
}
- #elif __EMSCRIPTEN__
+ #elif web
o << "Emscripten start address of the stack: " << emscripten_stack_get_base() << std::endl;
o << "Emscripten end address of the stack: " << emscripten_stack_get_end() << std::endl;
o << "Emscripten current stack pointer: " << emscripten_stack_get_current() << std::endl;
o << "Emscripten number of free bytes left on stack: " << emscripten_stack_get_free() << std::endl;
- #elif __PSP__
- o << "PSPdev MIPS Stack Trace: " << int pspDebugGetStackTrace() << std::endl;
+ #elif psp
+ o << "PSPdev MIPS Stack Trace: " << pspDebugGetStackTrace() << std::endl;
+ #elif dos
+ o << "DPMI virtual interrupt state: " << __dpmi_get_virtual_interrupt_state() << std::endl;
+ o << "DPMI selector increment value: " << __dpmi_get_selector_increment_value() << std::endl;
+ o << "DPMI coprocessor status: " << __dpmi_get_coprocessor_status() << std::endl;
+ o << "DPMI is 80387 processor?: " << _detect_80387() << std::endl;
#endif
o << "[Hardware]" << std::endl;
o << "number of logical CPU cores: " << SDL_GetNumLogicalCPUCores() << std::endl;
o << "System RAM size: " << SDL_GetSystemRAM() << " MiB" << std::endl;
+ o << "[Ruby]" << std::endl;
+ o << "Is GC was busy? " << rb_during_gc() << std::endl;
+ o << "[OpenGL]" << std::endl;
+ try{
+ o << "GL Vendor: " << glGetStringInt(GL_VENDOR) << std::endl;
+ o << "GL Renderer: " << glGetStringInt(GL_RENDERER) << std::endl;
+ o << "GL Version: " << glGetStringInt(GL_VERSION) << std::endl;
+ o << "GLSL Version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl;
+ o << "Shading language version: " << glGetStringInt(GL_SHADING_LANGUAGE_VERSION) << std::endl;
+ o << "GL Extensions: " << glGetStringInt(GL_EXTENSIONS) << std::endl;
+ }catch(const std::exception& e){
+ o << "Crashed before OpenGL initialization: " << e.what() << std::endl;
+ }
o.close();
}else{
- Debug() << "[CRASHLOG] Failed to write crashdump file";
- }
+ ErrorMsg("[CRASHLOG] Failed to write crashdump file");
+ }
+ }
+ if(do_crash){
+ rb_exit(-1);
}
-
- if(t != Exception::MEOW)
- throw Exception(t, msg);
}
void ErrorMsg(const char* message){
- SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", message, NULL);
+ if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", message, NULL)){
+ //TODO: error handling
+ }
}
void WarnMsg(const char* message){
- SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", message, NULL);
+ if(SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", message, NULL)){
+ //TODO: error handling
+ }
}
diff --git a/src/meow.h b/src/meow.h
index 55093fe..82b6f01 100644
--- a/src/meow.h
+++ b/src/meow.h
@@ -1,5 +1,5 @@
#include "exception.h"
-void crash(Exception::Type t, const char *fmt, ...);
+void crash(Exception::Type t, bool do_crash, const char *fmt, ...);
void ErrorMsg(const char* message);
void WarnMsg(const char* message);
diff --git a/src/modloader.cpp b/src/modloader.cpp
index 6ed87a2..17d488f 100644
--- a/src/modloader.cpp
+++ b/src/modloader.cpp
@@ -46,7 +46,7 @@ std::string sha512(const std::string str){
std::string sha256_file(const std::string &fn) {
FILE *file = fopen(fn.c_str(), "rb");
if (!file) {
- crash(Exception::ModLoaderError, "Failed to load mod, filesystem error.");
+ crash(Exception::IOError, true, "Failed to load mod, filesystem error.");
}
unsigned char buf[1024];
@@ -97,7 +97,7 @@ void ModLoader(){
std::string full = p.string();
int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0);
if (!ok) {
- crash(Exception::ModLoaderError, "PhysFS_mount failed: %s", PHYSFS_getLastError());
+ crash(Exception::ModLoaderError, false, "PhysFS_mount failed: %s", PHYSFS_getLastError());
}
Debug() << "[MODLOADER] " << full;
mod_list.push_back(full);
@@ -111,6 +111,6 @@ void ModLoader(){
Debug() << "[MODLOADER] BuildID: " << buildID;
modloader_is_enabled = true;
}catch(const std::exception& e){
- crash(Exception::ModLoaderError, "Something is wrong, Exception: %s ", e.what());
+ crash(Exception::ModLoaderError, true, "Something is wrong, Exception: %s ", e.what());
}
}
diff --git a/src/screen.cpp b/src/screen.cpp
index 974761c..17252b1 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -33,7 +33,7 @@ int screenMain(Config &conf){
win = SDL_CreateWindow("The Journal", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOW_RESIZABLE | SDL_WINDOW_TRANSPARENT);
if (!win){
- crash(Exception::MEOW, "Error creating window: %s", SDL_GetError());
+ crash(Exception::SDLError, true, "Error creating window: %s", SDL_GetError());
return 0;
}
diff --git a/src/security.h b/src/security.h
index b058803..fadf256 100644
--- a/src/security.h
+++ b/src/security.h
@@ -1,3 +1,3 @@
-inline char* securitystate = "unsandboxed";
+inline const char* securitystate = "unsandboxed";
void SecurityManagerInit();
void SecurityManagerDeInit();
diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp
index 811a2e0..ee712c6 100644
--- a/src/soundemitter.cpp
+++ b/src/soundemitter.cpp
@@ -222,7 +222,7 @@ SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){
buffer = handler.buffer;
if (!buffer){
- crash(Exception::MEOW, "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError());
+ crash(Exception::SDLError, false, "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError());
return 0;
}
diff --git a/src/table.cpp b/src/table.cpp
index 5d1d9c0..830ccf5 100644
--- a/src/table.cpp
+++ b/src/table.cpp
@@ -114,7 +114,7 @@ void Table::serialize(char *buffer) const{
Table *Table::deserialize(const char *data, int len){
if (len < 20)
- crash(Exception::RGSSError, "Marshal: Table: bad file format");
+ crash(Exception::RGSSError, true, "Marshal: Table: bad file format");
readInt32(&data);
int x = readInt32(&data);
@@ -123,10 +123,10 @@ Table *Table::deserialize(const char *data, int len){
int size = readInt32(&data);
if (size != x*y*z)
- crash(Exception::RGSSError, "Marshal: Table: bad file format");
+ crash(Exception::RGSSError, true, "Marshal: Table: bad file format");
if (len != 20 + x*y*z*2)
- crash(Exception::RGSSError, "Marshal: Table: bad file format");
+ crash(Exception::RGSSError, true, "Marshal: Table: bad file format");
Table *t = new Table(x, y, z);
SDL_memcpy(dataPtr(t->data), data, sizeof(int16_t)*size);
diff --git a/src/texpool.cpp b/src/texpool.cpp
index a6e481f..95ed82b 100644
--- a/src/texpool.cpp
+++ b/src/texpool.cpp
@@ -117,7 +117,7 @@ TEXFBO TexPool::request(int width, int height){
int maxSize = glState.caps.maxTexSize;
if (width > maxSize || height > maxSize){
- crash(Exception::MKXPError, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height);
+ crash(Exception::MKXPError, true, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height);
}
/* Nope, create it instead */
@@ -162,8 +162,7 @@ void TexPool::release(TEXFBO &obj){
CNodeList &bucket = p->poolHash[removedSize];
- std::list::iterator toRemove =
- std::find(bucket.begin(), bucket.end(), last);
+ std::list::iterator toRemove = std::find(bucket.begin(), bucket.end(), last);
assert(toRemove != bucket.end());
bucket.erase(toRemove);
diff --git a/src/vorbissource.cpp b/src/vorbissource.cpp
index d3c454c..bef5e5f 100644
--- a/src/vorbissource.cpp
+++ b/src/vorbissource.cpp
@@ -79,7 +79,7 @@ struct VorbisSource : ALDataSource{
if (error){
SDL_CloseIO(&src);
- crash(Exception::MKXPError, "Vorbisfile: Cannot read ogg file");
+ crash(Exception::MKXPError, true, "Vorbisfile: Cannot read ogg file");
}
/* Extract bitstream info */
@@ -89,7 +89,7 @@ struct VorbisSource : ALDataSource{
if (info.channels > 2){
ov_clear(&vf);
SDL_CloseIO(&src);
- crash(Exception::MKXPError, "Cannot handle audio with more than 2 channels");
+ crash(Exception::MKXPError, true, "Cannot handle audio with more than 2 channels");
}
info.alFormat = chooseALFormat(sizeof(int16_t), info.channels);
diff --git a/src/xdg-user-dir-lookup.c b/src/xdg-user-dir-lookup.c
index 0250a55..ebf99f8 100644
--- a/src/xdg-user-dir-lookup.c
+++ b/src/xdg-user-dir-lookup.c
@@ -29,6 +29,7 @@
#include
#include
+#include
/**
* xdg_user_dir_lookup_with_fallback:
* @type: a string specifying the type of directory