diff --git a/binding-mri/sunshine-binding.cpp b/binding-mri/sunshine-binding.cpp index b471869..db14af4 100644 --- a/binding-mri/sunshine-binding.cpp +++ b/binding-mri/sunshine-binding.cpp @@ -1,6 +1,13 @@ #include #include +static VALUE string_clone(VALUE self){ + if (!RB_TYPE_P(self, T_STRING)) { + rb_raise(rb_eTypeError, "wrong argument type (expected String)"); + } + return rb_obj_clone(self); +} + void SunshineBindingInit(){ printf("[SunshineBindingInit] Initializing Sunshine binding\n"); VALUE module = rb_define_module("Sunshine"); @@ -8,6 +15,7 @@ void SunshineBindingInit(){ rb_const_set(module, rb_intern("SDLVersion_minor"), INT2NUM(SDL_MINOR_VERSION)); rb_const_set(module, rb_intern("SDLVersion_micro"), INT2NUM(SDL_MICRO_VERSION)); rb_define_method(rb_cObject, "class", rb_obj_class, 0); + rb_define_method(rb_cString, "clone", RUBY_METHOD_FUNC(string_clone), 0); printf("[SunshineBindingInit] SDL version: %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION); printf("[SunshineBindingInit] Done\n"); } diff --git a/scripts/Interpreter_3.rb b/scripts/Interpreter_3.rb index b255c64..431f93d 100644 --- a/scripts/Interpreter_3.rb +++ b/scripts/Interpreter_3.rb @@ -35,7 +35,7 @@ class Interpreter else is_doc = false end - loop do + while true # 401: another line of text if @list[@index+1].code == 401 @index += 1 @@ -363,7 +363,7 @@ class Interpreter # Get indent indent = @list[@index].indent # Loop - loop do + while true # Return index @index -= 1 # If this event command is the same level as indent @@ -382,7 +382,7 @@ class Interpreter # Copy index to temporary variables temp_index = @index # Loop - loop do + while true # Advance index temp_index += 1 # If a fitting loop was not found @@ -453,7 +453,7 @@ class Interpreter # Initialize temporary variables temp_index = 0 # Loop - loop do + while true # If a fitting label was not found if temp_index >= @list.size-1 # Continue diff --git a/scripts/Interpreter_6.rb b/scripts/Interpreter_6.rb index 81783ba..808ba26 100644 --- a/scripts/Interpreter_6.rb +++ b/scripts/Interpreter_6.rb @@ -81,7 +81,7 @@ class Interpreter # Set goods list on new item $game_temp.shop_goods = [@parameters] # Loop - loop do + while true # Advance index @index += 1 # If next event command has shop on second line or after diff --git a/scripts/Interpreter_7.rb b/scripts/Interpreter_7.rb index c9944cf..0259d9b 100644 --- a/scripts/Interpreter_7.rb +++ b/scripts/Interpreter_7.rb @@ -255,7 +255,7 @@ class Interpreter # Set first line to script script = @list[@index].parameters[0] + "\n" # Loop - loop do + while true # If next event command is second line of script or after if @list[@index+1].code == 655 # Add second line or after to script diff --git a/scripts/Scene_Debug.rb b/scripts/Scene_Debug.rb index efbe563..00ed057 100644 --- a/scripts/Scene_Debug.rb +++ b/scripts/Scene_Debug.rb @@ -22,7 +22,7 @@ class Scene_Debug # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_End.rb b/scripts/Scene_End.rb index 89ab6a3..c29a611 100644 --- a/scripts/Scene_End.rb +++ b/scripts/Scene_End.rb @@ -19,7 +19,7 @@ class Scene_End # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_Equip.rb b/scripts/Scene_Equip.rb index 9636e69..9cfd4c2 100644 --- a/scripts/Scene_Equip.rb +++ b/scripts/Scene_Equip.rb @@ -42,7 +42,7 @@ class Scene_Equip # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_File.rb b/scripts/Scene_File.rb index f414033..89968a3 100644 --- a/scripts/Scene_File.rb +++ b/scripts/Scene_File.rb @@ -31,7 +31,7 @@ class Scene_File # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_Item.rb b/scripts/Scene_Item.rb index a19f85c..d9d0b19 100644 --- a/scripts/Scene_Item.rb +++ b/scripts/Scene_Item.rb @@ -21,7 +21,7 @@ class Scene_Item # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index bd6cdba..6082ec3 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -60,7 +60,7 @@ class Scene_Map # Transition run Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information @@ -112,7 +112,7 @@ class Scene_Map total_sec * 1000 % 1000) @in_game_timer.bitmap.fill_rect(0, 0, 140, 30, Color.new(0, 0, 0, 128)) - @in_game_timer.bitmap.draw_text(8, 0, 132, 30, time_string) + #@in_game_timer.bitmap.draw_text(8, 0, 132, 30, time_string) end if Input.quit? @@ -132,7 +132,7 @@ class Scene_Map end end # Loop - loop do + while true if $game_temp.prompt_wait > 0 $game_temp.prompt_wait -= 1 return diff --git a/scripts/Scene_Menu.rb b/scripts/Scene_Menu.rb index a293cb3..d6c16e5 100644 --- a/scripts/Scene_Menu.rb +++ b/scripts/Scene_Menu.rb @@ -57,7 +57,7 @@ class Scene_Menu # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_Name.rb b/scripts/Scene_Name.rb index 67de234..f19a9a0 100644 --- a/scripts/Scene_Name.rb +++ b/scripts/Scene_Name.rb @@ -15,7 +15,7 @@ class Scene_Name # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_Skill.rb b/scripts/Scene_Skill.rb index 1e704e0..adeeb2f 100644 --- a/scripts/Scene_Skill.rb +++ b/scripts/Scene_Skill.rb @@ -31,7 +31,7 @@ class Scene_Skill # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Scene_Status.rb b/scripts/Scene_Status.rb index 4465cf8..d6ded57 100644 --- a/scripts/Scene_Status.rb +++ b/scripts/Scene_Status.rb @@ -23,7 +23,7 @@ class Scene_Status # Execute transition Graphics.transition # Main loop - loop do + while true # Update game screen Graphics.update # Update input information diff --git a/scripts/Sprite_Timer.rb b/scripts/Sprite_Timer.rb index f0ec164..45b00b8 100644 --- a/scripts/Sprite_Timer.rb +++ b/scripts/Sprite_Timer.rb @@ -45,8 +45,8 @@ class Sprite_Timer < Sprite sec = @total_sec % 60 text = sprintf("%02d:%02d", min, sec) # Draw timer - self.bitmap.font.color.set(255, 255, 255) - self.bitmap.draw_text(self.bitmap.rect, text, 1) + #self.bitmap.font.color.set(255, 255, 255) + #self.bitmap.draw_text(self.bitmap.rect, text, 1) end end end diff --git a/scripts/Window_MainMenu.rb b/scripts/Window_MainMenu.rb index 51cf0af..98dd72f 100644 --- a/scripts/Window_MainMenu.rb +++ b/scripts/Window_MainMenu.rb @@ -53,7 +53,7 @@ class Window_MainMenu < Window_Selectable # Update item rect = Rect.new(w * index, 0, w - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) - self.contents.draw_text(rect, tr(@commands[index]), 1) + #self.contents.draw_text(rect, tr(@commands[index]), 1) end #-------------------------------------------------------------------------- # * Disable Item diff --git a/scripts/Window_NameInput.rb b/scripts/Window_NameInput.rb index 7dd40c8..91640e3 100644 --- a/scripts/Window_NameInput.rb +++ b/scripts/Window_NameInput.rb @@ -183,7 +183,7 @@ class Window_NameInput < Window_Base if old_slot == 0 @index = @table_size + @table_width - 1 else - loop do + while true @index -= 1 break if old_slot != mode_button_slot end @@ -199,7 +199,7 @@ class Window_NameInput < Window_Base if old_slot == -1 @index = @table_size else - loop do + while true @index += 1 break if old_slot != mode_button_slot end diff --git a/src/font.cpp b/src/font.cpp index 73ae4d1..b619f15 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -33,8 +33,7 @@ typedef std::pair FontKey; -struct FontSet -{ +struct FontSet{ /* 'Regular' style */ std::string regular; @@ -42,8 +41,7 @@ struct FontSet std::string other; }; -struct SharedFontStatePrivate -{ +struct SharedFontStatePrivate{ /* Maps: font family name, To: substituted family name, * as specified via configuration file / arguments */ BoostHash subs; @@ -57,13 +55,11 @@ struct SharedFontStatePrivate BoostHash pool; }; -SharedFontState::SharedFontState(const Config &conf) -{ +SharedFontState::SharedFontState(const Config &conf){ p = new SharedFontStatePrivate; /* Parse font substitutions */ - for (size_t i = 0; i < conf.fontSubs.size(); ++i) - { + for (size_t i = 0; i < conf.fontSubs.size(); ++i){ const std::string &raw = conf.fontSubs[i]; size_t sepPos = raw.find_first_of('>'); @@ -77,8 +73,7 @@ SharedFontState::SharedFontState(const Config &conf) } } -SharedFontState::~SharedFontState() -{ +SharedFontState::~SharedFontState(){ BoostHash::const_iterator iter; for (iter = p->pool.cbegin(); iter != p->pool.cend(); ++iter) TTF_CloseFont(iter->second); @@ -86,9 +81,7 @@ SharedFontState::~SharedFontState() delete p; } -void SharedFontState::initFontSetCB(SDL_IOStream* &ops, - const std::string &filename) -{ +void SharedFontState::initFontSetCB(SDL_IOStream* &ops, const std::string &filename){ TTF_Font *font = TTF_OpenFontIO(ops, false, 0); if (!font) @@ -107,9 +100,7 @@ void SharedFontState::initFontSetCB(SDL_IOStream* &ops, set.other = filename; } -TTF_Font *SharedFontState::getFont(std::string family, - int size) -{ +TTF_Font *SharedFontState::getFont(std::string family, int size){ /* Check for substitutions */ if (p->subs.contains(family)) family = p->subs[family]; @@ -133,9 +124,7 @@ TTF_Font *SharedFontState::getFont(std::string family, if (family.empty()){ throw Exception(Exception::RGSSError, "font does not exist"); - } - else - { + }else{ /* Use 'other' path as alternative in case * we have no 'regular' styled font asset */ const char *path = !req.regular.empty() @@ -173,10 +162,8 @@ void pickExistingFontName(const std::vector &names, * results in no text being drawn at all (same for "" and []); * we can't replicate this in mkxp due to the default substitute. */ - for (size_t i = 0; i < names.size(); ++i) - { - if (sfs.fontPresent(names[i])) - { + for (size_t i = 0; i < names.size(); ++i){ + if (sfs.fontPresent(names[i])){ out = names[i]; return; } @@ -281,8 +268,7 @@ bool Font::doesExist(const char *name){ } Font::Font(const std::vector *names, - int size) -{ + int size){ p = new FontPrivate(size ? size : FontPrivate::defaultSize); if (names) @@ -341,9 +327,7 @@ DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutline, bool, FontPrivate::defaultOutli DEF_ATTR_SIMPLE_STATIC(Font, DefaultColor, Color&, *FontPrivate::defaultColor) DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutColor, Color&, *FontPrivate::defaultOutColor) -void Font::setDefaultName(const std::vector &names, - const SharedFontState &sfs) -{ +void Font::setDefaultName(const std::vector &names, const SharedFontState &sfs){ pickExistingFontName(names, FontPrivate::defaultName, sfs); }