This commit is contained in:
ZakatTeamI2P 2026-05-04 11:41:06 +04:00
parent a81aa34411
commit e29a3c366c
18 changed files with 43 additions and 51 deletions

View file

@ -1,6 +1,13 @@
#include <ruby.h> #include <ruby.h>
#include <SDL3/SDL_version.h> #include <SDL3/SDL_version.h>
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(){ void SunshineBindingInit(){
printf("[SunshineBindingInit] Initializing Sunshine binding\n"); printf("[SunshineBindingInit] Initializing Sunshine binding\n");
VALUE module = rb_define_module("Sunshine"); 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_minor"), INT2NUM(SDL_MINOR_VERSION));
rb_const_set(module, rb_intern("SDLVersion_micro"), INT2NUM(SDL_MICRO_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_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] SDL version: %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
printf("[SunshineBindingInit] Done\n"); printf("[SunshineBindingInit] Done\n");
} }

View file

@ -35,7 +35,7 @@ class Interpreter
else else
is_doc = false is_doc = false
end end
loop do while true
# 401: another line of text # 401: another line of text
if @list[@index+1].code == 401 if @list[@index+1].code == 401
@index += 1 @index += 1
@ -363,7 +363,7 @@ class Interpreter
# Get indent # Get indent
indent = @list[@index].indent indent = @list[@index].indent
# Loop # Loop
loop do while true
# Return index # Return index
@index -= 1 @index -= 1
# If this event command is the same level as indent # If this event command is the same level as indent
@ -382,7 +382,7 @@ class Interpreter
# Copy index to temporary variables # Copy index to temporary variables
temp_index = @index temp_index = @index
# Loop # Loop
loop do while true
# Advance index # Advance index
temp_index += 1 temp_index += 1
# If a fitting loop was not found # If a fitting loop was not found
@ -453,7 +453,7 @@ class Interpreter
# Initialize temporary variables # Initialize temporary variables
temp_index = 0 temp_index = 0
# Loop # Loop
loop do while true
# If a fitting label was not found # If a fitting label was not found
if temp_index >= @list.size-1 if temp_index >= @list.size-1
# Continue # Continue

View file

@ -81,7 +81,7 @@ class Interpreter
# Set goods list on new item # Set goods list on new item
$game_temp.shop_goods = [@parameters] $game_temp.shop_goods = [@parameters]
# Loop # Loop
loop do while true
# Advance index # Advance index
@index += 1 @index += 1
# If next event command has shop on second line or after # If next event command has shop on second line or after

View file

@ -255,7 +255,7 @@ class Interpreter
# Set first line to script # Set first line to script
script = @list[@index].parameters[0] + "\n" script = @list[@index].parameters[0] + "\n"
# Loop # Loop
loop do while true
# If next event command is second line of script or after # If next event command is second line of script or after
if @list[@index+1].code == 655 if @list[@index+1].code == 655
# Add second line or after to script # Add second line or after to script

View file

@ -22,7 +22,7 @@ class Scene_Debug
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -19,7 +19,7 @@ class Scene_End
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -42,7 +42,7 @@ class Scene_Equip
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -31,7 +31,7 @@ class Scene_File
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -21,7 +21,7 @@ class Scene_Item
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -60,7 +60,7 @@ class Scene_Map
# Transition run # Transition run
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information
@ -112,7 +112,7 @@ class Scene_Map
total_sec * 1000 % 1000) total_sec * 1000 % 1000)
@in_game_timer.bitmap.fill_rect(0, 0, 140, 30, Color.new(0, 0, 0, 128)) @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 end
if Input.quit? if Input.quit?
@ -132,7 +132,7 @@ class Scene_Map
end end
end end
# Loop # Loop
loop do while true
if $game_temp.prompt_wait > 0 if $game_temp.prompt_wait > 0
$game_temp.prompt_wait -= 1 $game_temp.prompt_wait -= 1
return return

View file

@ -57,7 +57,7 @@ class Scene_Menu
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -15,7 +15,7 @@ class Scene_Name
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -31,7 +31,7 @@ class Scene_Skill
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -23,7 +23,7 @@ class Scene_Status
# Execute transition # Execute transition
Graphics.transition Graphics.transition
# Main loop # Main loop
loop do while true
# Update game screen # Update game screen
Graphics.update Graphics.update
# Update input information # Update input information

View file

@ -45,8 +45,8 @@ class Sprite_Timer < Sprite
sec = @total_sec % 60 sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec) text = sprintf("%02d:%02d", min, sec)
# Draw timer # Draw timer
self.bitmap.font.color.set(255, 255, 255) #self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(self.bitmap.rect, text, 1) #self.bitmap.draw_text(self.bitmap.rect, text, 1)
end end
end end
end end

View file

@ -53,7 +53,7 @@ class Window_MainMenu < Window_Selectable
# Update item # Update item
rect = Rect.new(w * index, 0, w - 32, 32) rect = Rect.new(w * index, 0, w - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) 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 end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# * Disable Item # * Disable Item

View file

@ -183,7 +183,7 @@ class Window_NameInput < Window_Base
if old_slot == 0 if old_slot == 0
@index = @table_size + @table_width - 1 @index = @table_size + @table_width - 1
else else
loop do while true
@index -= 1 @index -= 1
break if old_slot != mode_button_slot break if old_slot != mode_button_slot
end end
@ -199,7 +199,7 @@ class Window_NameInput < Window_Base
if old_slot == -1 if old_slot == -1
@index = @table_size @index = @table_size
else else
loop do while true
@index += 1 @index += 1
break if old_slot != mode_button_slot break if old_slot != mode_button_slot
end end

View file

@ -33,8 +33,7 @@
typedef std::pair<std::string, int> FontKey; typedef std::pair<std::string, int> FontKey;
struct FontSet struct FontSet{
{
/* 'Regular' style */ /* 'Regular' style */
std::string regular; std::string regular;
@ -42,8 +41,7 @@ struct FontSet
std::string other; std::string other;
}; };
struct SharedFontStatePrivate struct SharedFontStatePrivate{
{
/* Maps: font family name, To: substituted family name, /* Maps: font family name, To: substituted family name,
* as specified via configuration file / arguments */ * as specified via configuration file / arguments */
BoostHash<std::string, std::string> subs; BoostHash<std::string, std::string> subs;
@ -57,13 +55,11 @@ struct SharedFontStatePrivate
BoostHash<FontKey, TTF_Font*> pool; BoostHash<FontKey, TTF_Font*> pool;
}; };
SharedFontState::SharedFontState(const Config &conf) SharedFontState::SharedFontState(const Config &conf){
{
p = new SharedFontStatePrivate; p = new SharedFontStatePrivate;
/* Parse font substitutions */ /* 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]; const std::string &raw = conf.fontSubs[i];
size_t sepPos = raw.find_first_of('>'); size_t sepPos = raw.find_first_of('>');
@ -77,8 +73,7 @@ SharedFontState::SharedFontState(const Config &conf)
} }
} }
SharedFontState::~SharedFontState() SharedFontState::~SharedFontState(){
{
BoostHash<FontKey, TTF_Font*>::const_iterator iter; BoostHash<FontKey, TTF_Font*>::const_iterator iter;
for (iter = p->pool.cbegin(); iter != p->pool.cend(); ++iter) for (iter = p->pool.cbegin(); iter != p->pool.cend(); ++iter)
TTF_CloseFont(iter->second); TTF_CloseFont(iter->second);
@ -86,9 +81,7 @@ SharedFontState::~SharedFontState()
delete p; delete p;
} }
void SharedFontState::initFontSetCB(SDL_IOStream* &ops, void SharedFontState::initFontSetCB(SDL_IOStream* &ops, const std::string &filename){
const std::string &filename)
{
TTF_Font *font = TTF_OpenFontIO(ops, false, 0); TTF_Font *font = TTF_OpenFontIO(ops, false, 0);
if (!font) if (!font)
@ -107,9 +100,7 @@ void SharedFontState::initFontSetCB(SDL_IOStream* &ops,
set.other = filename; set.other = filename;
} }
TTF_Font *SharedFontState::getFont(std::string family, TTF_Font *SharedFontState::getFont(std::string family, int size){
int size)
{
/* Check for substitutions */ /* Check for substitutions */
if (p->subs.contains(family)) if (p->subs.contains(family))
family = p->subs[family]; family = p->subs[family];
@ -133,9 +124,7 @@ TTF_Font *SharedFontState::getFont(std::string family,
if (family.empty()){ if (family.empty()){
throw Exception(Exception::RGSSError, "font does not exist"); throw Exception(Exception::RGSSError, "font does not exist");
} }else{
else
{
/* Use 'other' path as alternative in case /* Use 'other' path as alternative in case
* we have no 'regular' styled font asset */ * we have no 'regular' styled font asset */
const char *path = !req.regular.empty() const char *path = !req.regular.empty()
@ -173,10 +162,8 @@ void pickExistingFontName(const std::vector<std::string> &names,
* results in no text being drawn at all (same for "" and []); * results in no text being drawn at all (same for "" and []);
* we can't replicate this in mkxp due to the default substitute. */ * we can't replicate this in mkxp due to the default substitute. */
for (size_t i = 0; i < names.size(); ++i) for (size_t i = 0; i < names.size(); ++i){
{ if (sfs.fontPresent(names[i])){
if (sfs.fontPresent(names[i]))
{
out = names[i]; out = names[i];
return; return;
} }
@ -281,8 +268,7 @@ bool Font::doesExist(const char *name){
} }
Font::Font(const std::vector<std::string> *names, Font::Font(const std::vector<std::string> *names,
int size) int size){
{
p = new FontPrivate(size ? size : FontPrivate::defaultSize); p = new FontPrivate(size ? size : FontPrivate::defaultSize);
if (names) 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, DefaultColor, Color&, *FontPrivate::defaultColor)
DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutColor, Color&, *FontPrivate::defaultOutColor) DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutColor, Color&, *FontPrivate::defaultOutColor)
void Font::setDefaultName(const std::vector<std::string> &names, void Font::setDefaultName(const std::vector<std::string> &names, const SharedFontState &sfs){
const SharedFontState &sfs)
{
pickExistingFontName(names, FontPrivate::defaultName, sfs); pickExistingFontName(names, FontPrivate::defaultName, sfs);
} }