mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-20 22:09:55 +00:00
Patcher for 16:9
This commit is contained in:
parent
e2f497e66d
commit
aa65d1783b
23 changed files with 154 additions and 166 deletions
|
|
@ -209,7 +209,6 @@ void graphicsBindingInit(){
|
|||
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
|
||||
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
|
||||
|
||||
if (rgssVer >= 2){
|
||||
_rb_define_module_function(module, "width", graphicsWidth);
|
||||
_rb_define_module_function(module, "height", graphicsHeight);
|
||||
_rb_define_module_function(module, "wait", graphicsWait);
|
||||
|
|
@ -219,7 +218,6 @@ void graphicsBindingInit(){
|
|||
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
|
||||
|
||||
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
||||
}
|
||||
|
||||
if (rgssVer >= 3){
|
||||
_rb_define_module_function(module, "play_movie", graphicsPlayMovie);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ void SunshineBindingInit(){
|
|||
rb_const_set(module, rb_intern("SDLVersion_major"), INT2NUM(SDL_MAJOR_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));
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("[SunshineBindingInit] SDL version: %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@
|
|||
#
|
||||
# fixedAspectRatio=true
|
||||
|
||||
# 16:9 support
|
||||
# EXPEREMENTAL!
|
||||
# EnableSixteenByNine=false
|
||||
|
||||
# Apply linear interpolation when game screen
|
||||
# is upscaled
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ class Credits_Message
|
|||
def initialize
|
||||
@timer = 0
|
||||
|
||||
@viewport = Viewport.new(0, 0, 640, 480)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@sprite_bg = Sprite.new(@viewport)
|
||||
@sprite_bg.bitmap = Bitmap.new(640, 480)
|
||||
@sprite_bg.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||
if $game_switches[104]
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 255))
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0, 255))
|
||||
else
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(255, 255, 255, 255))
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(255, 255, 255, 255))
|
||||
end
|
||||
@sprite_text = Sprite.new(@viewport)
|
||||
@contents = Bitmap.new(320, 240)
|
||||
|
|
@ -61,9 +61,9 @@ class Credits_Message
|
|||
def refresh
|
||||
|
||||
if $game_switches[104]
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 255))
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0, 255))
|
||||
else
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(255, 255, 255, 255))
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(255, 255, 255, 255))
|
||||
end
|
||||
|
||||
# Initialize
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ class Desktop_Message
|
|||
# * Object Initialization
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@viewport = Viewport.new(0, 0, 640, 480)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@sprite_bg = Sprite.new(@viewport)
|
||||
@sprite_bg.bitmap = RPG::Cache.picture('cg_desktop_messagebox') #Bitmap.new(640, 480)
|
||||
@sprite_bg.zoom_x = @sprite_bg.zoom_y = 2
|
||||
@sprite_text = Sprite.new(@viewport)
|
||||
@contents = Bitmap.new(640, HEIGHT)
|
||||
@contents = Bitmap.new(Graphics.width, HEIGHT)
|
||||
Language.register_text_sprite(self.class.name + "_contents", @contents)
|
||||
@sprite_text.bitmap = @contents
|
||||
@sprite_text.y = (480 - HEIGHT) / 2
|
||||
@sprite_text.y = (Graphics.height - HEIGHT) / 2
|
||||
@sprite_bg.z = 0
|
||||
@sprite_text.z = 1
|
||||
@sprite_text.zoom_x = @sprite_text.zoom_y = 1
|
||||
|
|
@ -119,7 +119,7 @@ class Desktop_Message
|
|||
@contents.clear
|
||||
@contents.font.color = Color.new(44, 37, 54, 255)
|
||||
y_top = (HEIGHT - widths.length * 24) / 2
|
||||
x = (640 - widths[0]) / 2
|
||||
x = (Graphics.width - widths[0]) / 2
|
||||
y = 0
|
||||
|
||||
# Get 1 text character in c (loop until unable to get text)
|
||||
|
|
@ -127,7 +127,7 @@ class Desktop_Message
|
|||
# \n
|
||||
if c == "\n"
|
||||
y += 1
|
||||
x = (640 - widths[y]) / 2
|
||||
x = (Graphics.width - widths[y]) / 2
|
||||
next
|
||||
end
|
||||
# \c[n]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Doc_Message
|
|||
# * Object Initialization
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@viewport = Viewport.new(0, 0, 640, 480)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@sprite_bg = Sprite.new(@viewport)
|
||||
@sprite_scroll_up = Sprite.new(@viewport)
|
||||
@sprite_scroll_down = Sprite.new(@viewport)
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ class Ed_Message
|
|||
# * Object Initialization
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@viewport = Viewport.new(0, 0, 640, 480)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@sprite_bg = Sprite.new(@viewport)
|
||||
@sprite_bg.bitmap = Bitmap.new(640, 480)
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 128))
|
||||
@sprite_bg.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||
@sprite_bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0, 128))
|
||||
@sprite_text = Sprite.new(@viewport)
|
||||
@contents = Bitmap.new(640, HEIGHT)
|
||||
@contents = Bitmap.new(Graphics.width, HEIGHT)
|
||||
Language.register_text_sprite(self.class.name + "_contents", @contents)
|
||||
@sprite_text.bitmap = @contents
|
||||
@sprite_text.y = (480 - HEIGHT) / 2
|
||||
@sprite_text.y = (Graphics.height - HEIGHT) / 2
|
||||
@sprite_bg.z = 0
|
||||
@sprite_text.z = 1
|
||||
@viewport.z = 9999
|
||||
|
|
@ -123,7 +123,7 @@ class Ed_Message
|
|||
@contents.clear
|
||||
@contents.font.color = Color.new(255, 255, 255, 255)
|
||||
y_top = (HEIGHT - widths.length * 24) / 2
|
||||
x = (640 - widths[0]) / 2
|
||||
x = (Graphics.width - widths[0]) / 2
|
||||
y = 0
|
||||
|
||||
# Get 1 text character in c (loop until unable to get text)
|
||||
|
|
@ -131,7 +131,7 @@ class Ed_Message
|
|||
# \n
|
||||
if c == "\n"
|
||||
y += 1
|
||||
x = (640 - widths[y]) / 2
|
||||
x = (Graphics.width - widths[y]) / 2
|
||||
next
|
||||
end
|
||||
# \c[n]
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ class FastTravel
|
|||
ACTIVE_MARGIN = MARGIN * 2 + 20
|
||||
|
||||
def initialize
|
||||
@viewport = Viewport.new(0, 0, 640, 480)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@bg = Sprite.new(@viewport)
|
||||
@bg.bitmap = Bitmap.new(640, 480)
|
||||
@bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 128))
|
||||
@bg.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||
@bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0, 128))
|
||||
@title = Sprite.new(@viewport)
|
||||
Language.register_text_sprite(self.class.name + "_title", @title)
|
||||
@title.bitmap = Bitmap.new(320, TITLE_MARGIN)
|
||||
|
|
|
|||
|
|
@ -12,9 +12,14 @@ class Game_Player < Game_Character
|
|||
#--------------------------------------------------------------------------
|
||||
# * Invariables
|
||||
#--------------------------------------------------------------------------
|
||||
CENTER_X = (320 - 16) * 4 # Center screen x-coordinate * 4
|
||||
CENTER_Y = (240 - 16) * 4 # Center screen y-coordinate * 4
|
||||
#--------------------------------------------------------------------------
|
||||
if Graphics.width == 1280
|
||||
CENTER_X = 2560 - 16 # Center screen x-coordinate * 2
|
||||
CENTER_Y = 2880 - 16 # Center screen y-coordinate * 2
|
||||
else
|
||||
CENTER_X = (320 - 16) * 4 # Center screen x-coordinate * 4
|
||||
CENTER_Y = (240 - 16) * 4 # Center screen y-coordinate * 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# * Passable Determinants
|
||||
# x : x-coordinate
|
||||
# y : y-coordinate
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ class Particle
|
|||
@sprite.bitmap = bitmap
|
||||
@sprite.ox = bitmap.width / 2
|
||||
@sprite.oy = bitmap.height / 2
|
||||
self.x = rand(640)
|
||||
self.y = rand(480)
|
||||
self.x = rand(Graphics.width)
|
||||
self.y = rand(Graphics.height)
|
||||
end
|
||||
|
||||
# Link various things to the sprite
|
||||
|
|
@ -17,8 +17,8 @@ class Particle
|
|||
@x = val
|
||||
width = @sprite.bitmap.width * @sprite.zoom_x
|
||||
if @x < -width
|
||||
@x = 640 + width
|
||||
elsif @x > 640 + width
|
||||
@x = Graphics.width + width
|
||||
elsif @x > Graphics.width + width
|
||||
@x = -width
|
||||
end
|
||||
@sprite.x = @x
|
||||
|
|
@ -30,8 +30,8 @@ class Particle
|
|||
@y = val
|
||||
height = @sprite.bitmap.height * @sprite.zoom_y
|
||||
if @y < -height
|
||||
@y = 480 + height
|
||||
elsif @y > 480 + height
|
||||
@y = Graphics.height + height
|
||||
elsif @y > Graphics.height + height
|
||||
@y = -height
|
||||
end
|
||||
@sprite.y = @y
|
||||
|
|
|
|||
|
|
@ -32,16 +32,16 @@ class Scene_Map
|
|||
@item_menu_refresh = false
|
||||
# Make item icon
|
||||
@item_icon = Sprite.new
|
||||
@item_icon.x = 640 - 64
|
||||
@item_icon.y = 480 - 64
|
||||
@item_icon.x = Graphics.width - 64
|
||||
@item_icon.y = Graphics.height - 64
|
||||
@item_icon.z = 9000
|
||||
@item_icon.zoom_x = 2.0
|
||||
@item_icon.zoom_y = 2.0
|
||||
@item_id = 0
|
||||
# Make item flash (for clover)
|
||||
@item_icon_flash = Sprite.new
|
||||
@item_icon_flash.x = 640 - 64
|
||||
@item_icon_flash.y = 480 - 64
|
||||
@item_icon_flash.x = Graphics.width - 64
|
||||
@item_icon_flash.y = Graphics.height - 64
|
||||
@item_icon_flash.z = 10000
|
||||
@item_icon_flash.zoom_x = 2.0
|
||||
@item_icon_flash.zoom_y = 2.0
|
||||
|
|
@ -53,8 +53,8 @@ class Scene_Map
|
|||
@window_settings = Window_Settings.new
|
||||
# Fade to black transition
|
||||
@blackfade = Sprite.new
|
||||
@blackfade.bitmap = Bitmap.new(640, 480)
|
||||
@blackfade.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0))
|
||||
@blackfade.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||
@blackfade.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0))
|
||||
@blackfade.visible = false
|
||||
@blackfade.z = 9999
|
||||
# Transition run
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#==============================================================================
|
||||
|
||||
class Scene_Title
|
||||
MENU_X = 640 - 150
|
||||
MENU_Y = 480 - 100
|
||||
MENU_X = Graphics.width - 150
|
||||
MENU_Y = Graphics.height - 100
|
||||
SDLVer = "#{Sunshine::SDLVersion_major}.#{Sunshine::SDLVersion_minor}.#{Sunshine::SDLVersion_micro}"
|
||||
#--------------------------------------------------------------------------
|
||||
# * Main Processing
|
||||
|
|
@ -47,9 +47,17 @@ class Scene_Title
|
|||
@sprite.bitmap = RPG::Cache.title(translation_name)
|
||||
else
|
||||
if File.exist?("badend.lock")
|
||||
@sprite.bitmap = RPG::Cache.title("badend")
|
||||
if Graphics.width == 1280
|
||||
@sprite.bitmap = RPG::Cache.title("badend_16")
|
||||
else
|
||||
@sprite.bitmap = RPG::Cache.title("badend")
|
||||
end
|
||||
else
|
||||
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
|
||||
if Graphics.width == 1280
|
||||
@sprite.bitmap = RPG::Cache.title("normal_16")
|
||||
else
|
||||
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
# check for debug file to add debug items
|
||||
|
|
@ -67,7 +75,7 @@ class Scene_Title
|
|||
# Create/render menu options
|
||||
@menu = Sprite.new
|
||||
@menu.z += 1
|
||||
@menu.bitmap = Bitmap.new(640, 480)
|
||||
@menu.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||
@menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start"))
|
||||
@menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings"))
|
||||
@menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ class Spriteset_Map
|
|||
#--------------------------------------------------------------------------
|
||||
def initialize(spriteset = nil)
|
||||
# Make viewports
|
||||
@viewport = Viewport.new(0, 0, 640, 480)
|
||||
@viewport_bg = Viewport.new(0, 0, 640, 480)
|
||||
@viewport_pics = Viewport.new(0, 0, 640, 480)
|
||||
@viewport_particles = Viewport.new(0, 0, 640, 480)
|
||||
@viewport_lights = Viewport.new(0, 0, 640, 480)
|
||||
@viewport_flash = Viewport.new(0, 0, 640, 480)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport_bg = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport_pics = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport_particles = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport_lights = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport_flash = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
|
||||
@viewport_bg.z = -500
|
||||
@viewport_lights.z = 200
|
||||
|
|
@ -80,7 +80,11 @@ class Spriteset_Map
|
|||
# Make lightbulb sprite
|
||||
@bulb = Sprite.new(@viewport_lights)
|
||||
@bulb.x = -80
|
||||
@bulb.bitmap = RPG::Cache.light('bulb')
|
||||
if Graphics.width == 1280
|
||||
@bulb.bitmap = RPG::Cache.light('bulb_16')
|
||||
else
|
||||
@bulb.bitmap = RPG::Cache.light('bulb')
|
||||
end
|
||||
@bulb.opacity = has_lightbulb? ? 255 : 0
|
||||
# Panorama animation timer
|
||||
@pan_animate_timer = 0
|
||||
|
|
@ -176,10 +180,11 @@ class Spriteset_Map
|
|||
@panorama2.opacity = 0
|
||||
@pan_frame_index = 0
|
||||
end
|
||||
@panorama.bitmap = RPG::Cache.panorama(@panorama_name + (1 + @pan_frame_index).to_s, @panorama_hue)
|
||||
@panorama2.bitmap = RPG::Cache.panorama(@panorama_name + (1 + @pan_frame_index).to_s, @panorama_hue)
|
||||
@panorama.bitmap = RPG::Cache.panorama(@panorama_name + (1 + @pan_frame_index).to_s, @panorama_hue)
|
||||
@panorama2.bitmap = RPG::Cache.panorama(@panorama_name + (1 + @pan_frame_index).to_s, @panorama_hue)
|
||||
|
||||
else
|
||||
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
|
||||
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
|
||||
end
|
||||
end
|
||||
Graphics.frame_reset
|
||||
|
|
@ -247,13 +252,13 @@ class Spriteset_Map
|
|||
$game_map.pan_move_offset += 1
|
||||
end
|
||||
if $game_map.clamped_x
|
||||
x = ($game_player.real_x.to_f / (($game_map.width - 1) * 128)) * (@panorama.bitmap.width * $game_map.pan_zoom - 640)
|
||||
x = ($game_player.real_x.to_f / (($game_map.width - 1) * 128)) * (@panorama.bitmap.width * $game_map.pan_zoom - Graphics.width)
|
||||
@panorama.ox = x < 0.0 ? 0.0 : x
|
||||
else
|
||||
@panorama.ox = $game_map.display_x / ($game_map.pan_onetoone ? 4 : 8)
|
||||
end
|
||||
if $game_map.clamped_y
|
||||
y = ($game_player.real_y.to_f / (($game_map.height - 1) * 128)) * (@panorama.bitmap.height * $game_map.pan_zoom - 480)
|
||||
y = ($game_player.real_y.to_f / (($game_map.height - 1) * 128)) * (@panorama.bitmap.height * $game_map.pan_zoom - Graphics.height)
|
||||
@panorama.oy = y < 0.0 ? 0.0 : y
|
||||
else
|
||||
@panorama.oy = $game_map.pan_offset_y + $game_map.display_y / ($game_map.pan_onetoone ? 4 : 8)
|
||||
|
|
@ -304,10 +309,10 @@ class Spriteset_Map
|
|||
# no point in updating the sprite if offscreen
|
||||
# this greatly increases performance on larger maps
|
||||
|
||||
((sprite.character.real_x + (sprite.ox*4) > $game_map.display_x - 128) &&
|
||||
(sprite.character.real_x - (sprite.ox*4) < $game_map.display_x + (21 * 128)) &&
|
||||
(sprite.character.real_y + (sprite.oy*4) > ($game_map.display_y) - 128) &&
|
||||
(sprite.character.real_y - (sprite.oy*4) < ($game_map.display_y) + (17 * 128)))
|
||||
((sprite.character.real_x + (sprite.ox*4) > Graphics.width - 128) &&
|
||||
(sprite.character.real_x - (sprite.ox*4) < Graphics.width + (21 * 128)) &&
|
||||
(sprite.character.real_y + (sprite.oy*4) > (Graphics.height) - 128) &&
|
||||
(sprite.character.real_y - (sprite.oy*4) < (Graphics.height) + (17 * 128)))
|
||||
sprite.update
|
||||
else
|
||||
sprite.update_fast
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ class Window_Settings
|
|||
end
|
||||
end
|
||||
def initialize
|
||||
@viewport = Viewport.new(0, 0, 640, 480)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@bg = Sprite.new(@viewport)
|
||||
@bg.bitmap = Bitmap.new(640, 480)
|
||||
@bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 128))
|
||||
@bg.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||
@bg.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0, 128))
|
||||
@title = Sprite.new(@viewport)
|
||||
@title.bitmap = Bitmap.new(320, TITLE_MARGIN)
|
||||
@title.bitmap.font.size = 40
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Window_Status < Window_Base
|
|||
# actor : actor
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(actor)
|
||||
super(0, 0, 640, 480)
|
||||
super(0, 0, Graphics.width, Graphics.height)
|
||||
self.contents = Bitmap.new(width - 32, height - 32)
|
||||
@actor = actor
|
||||
refresh
|
||||
|
|
|
|||
|
|
@ -55,18 +55,15 @@
|
|||
|
||||
/* Normalize (= ensure width and
|
||||
* height are positive) */
|
||||
static IntRect normalizedRect(const IntRect &rect)
|
||||
{
|
||||
static IntRect normalizedRect(const IntRect &rect){
|
||||
IntRect norm = rect;
|
||||
|
||||
if (norm.w < 0)
|
||||
{
|
||||
if (norm.w < 0){
|
||||
norm.w = -norm.w;
|
||||
norm.x -= norm.w;
|
||||
}
|
||||
|
||||
if (norm.h < 0)
|
||||
{
|
||||
if (norm.h < 0){
|
||||
norm.h = -norm.h;
|
||||
norm.y -= norm.h;
|
||||
}
|
||||
|
|
@ -74,8 +71,7 @@ static IntRect normalizedRect(const IntRect &rect)
|
|||
return norm;
|
||||
}
|
||||
|
||||
struct BitmapPrivate
|
||||
{
|
||||
struct BitmapPrivate{
|
||||
Bitmap *self;
|
||||
|
||||
TEXFBO gl;
|
||||
|
|
@ -981,8 +977,7 @@ static void applyShadow(SDL_Surface *&in, const SDL_PixelFormatDetails* fm, cons
|
|||
in = out;
|
||||
}
|
||||
|
||||
void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||
{
|
||||
void Bitmap::drawText(const IntRect &rect, const char *str, int align){
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
|
@ -1021,8 +1016,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
|
||||
/* outline using TTF_Outline and blending it together with SDL_BlitSurface
|
||||
* FIXME: outline is forced to have the same opacity as the font color */
|
||||
if (p->font->getOutline())
|
||||
{
|
||||
if (p->font->getOutline()){
|
||||
SDL_Color co = outColor.toSDLColor();
|
||||
co.a = 255;
|
||||
SDL_Surface *outline;
|
||||
|
|
@ -1046,8 +1040,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
|
||||
int alignX = rect.x;
|
||||
|
||||
switch (align)
|
||||
{
|
||||
switch (align){
|
||||
default:
|
||||
case Left :
|
||||
break;
|
||||
|
|
@ -1078,10 +1071,8 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
|
||||
bool fastBlit = false; //!p->touchesTaintedArea(posRect) && txtAlpha == 1.0f;
|
||||
|
||||
if (fastBlit)
|
||||
{
|
||||
if (squeeze == 1.0f && !shState->config().subImageFix)
|
||||
{
|
||||
if (fastBlit){
|
||||
if (squeeze == 1.0f && !shState->config().subImageFix){
|
||||
/* Even faster: upload directly to bitmap texture.
|
||||
* We have to make sure the posRect lies within the texture
|
||||
* boundaries or texSubImage will generate errors.
|
||||
|
|
@ -1102,13 +1093,11 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
|
||||
/* If we have no intersection at all,
|
||||
* there's nothing to upload to begin with */
|
||||
if (SDL_GetRectIntersection(&btmRect, &txtRect, &inters))
|
||||
{
|
||||
if (SDL_GetRectIntersection(&btmRect, &txtRect, &inters)){
|
||||
bool subImage = false;
|
||||
int subSrcX = 0, subSrcY = 0;
|
||||
|
||||
if (inters.w != txtRect.w || inters.h != txtRect.h)
|
||||
{
|
||||
if (inters.w != txtRect.w || inters.h != txtRect.h){
|
||||
/* Clip the text surface */
|
||||
subSrcX = inters.x - txtRect.x;
|
||||
subSrcY = inters.y - txtRect.y;
|
||||
|
|
@ -1122,14 +1111,12 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
|
||||
TEX::bind(p->gl.tex);
|
||||
|
||||
if (!subImage)
|
||||
{
|
||||
if (!subImage){
|
||||
TEX::uploadSubImage(posRect.x, posRect.y,
|
||||
posRect.w, posRect.h,
|
||||
txtSurf->pixels, GL_RGBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
GLMeta::subRectImageUpload(txtSurf->w, subSrcX, subSrcY,
|
||||
posRect.x, posRect.y,
|
||||
posRect.w, posRect.h,
|
||||
|
|
@ -1138,8 +1125,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
/* Squeezing involved: need to use intermediary TexFBO */
|
||||
TEXFBO &gpTF = shState->gpTexFBO(txtSurf->w, txtSurf->h);
|
||||
|
||||
|
|
@ -1153,8 +1139,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
GLMeta::blitEnd();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
/* Aquire a partial copy of the destination
|
||||
* buffer we're about to render to */
|
||||
TEXFBO &gpTex2 = shState->gpTexFBO(posRect.w, posRect.h);
|
||||
|
|
@ -1199,9 +1184,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
}
|
||||
|
||||
/* http://www.lemoda.net/c/utf8-to-ucs2/index.html */
|
||||
static uint16_t utf8_to_ucs2(const char *_input,
|
||||
const char **end_ptr)
|
||||
{
|
||||
static uint16_t utf8_to_ucs2(const char *_input, const char **end_ptr){
|
||||
const unsigned char *input =
|
||||
reinterpret_cast<const unsigned char*>(_input);
|
||||
*end_ptr = _input;
|
||||
|
|
@ -1209,15 +1192,13 @@ static uint16_t utf8_to_ucs2(const char *_input,
|
|||
if (input[0] == 0)
|
||||
return -1;
|
||||
|
||||
if (input[0] < 0x80)
|
||||
{
|
||||
if (input[0] < 0x80){
|
||||
*end_ptr = _input + 1;
|
||||
|
||||
return input[0];
|
||||
}
|
||||
|
||||
if ((input[0] & 0xE0) == 0xE0)
|
||||
{
|
||||
if ((input[0] & 0xE0) == 0xE0){
|
||||
if (input[1] == 0 || input[2] == 0)
|
||||
return -1;
|
||||
|
||||
|
|
@ -1228,8 +1209,7 @@ static uint16_t utf8_to_ucs2(const char *_input,
|
|||
(input[2] & 0x3F);
|
||||
}
|
||||
|
||||
if ((input[0] & 0xC0) == 0xC0)
|
||||
{
|
||||
if ((input[0] & 0xC0) == 0xC0){
|
||||
if (input[1] == 0)
|
||||
return -1;
|
||||
|
||||
|
|
@ -1242,8 +1222,7 @@ static uint16_t utf8_to_ucs2(const char *_input,
|
|||
return -1;
|
||||
}
|
||||
|
||||
IntRect Bitmap::textSize(const char *str)
|
||||
{
|
||||
IntRect Bitmap::textSize(const char *str){
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
|
@ -1275,46 +1254,38 @@ IntRect Bitmap::textSize(const char *str)
|
|||
|
||||
DEF_ATTR_RD_SIMPLE(Bitmap, Font, Font&, *p->font)
|
||||
|
||||
void Bitmap::setFont(Font &value)
|
||||
{
|
||||
void Bitmap::setFont(Font &value){
|
||||
*p->font = value;
|
||||
}
|
||||
|
||||
void Bitmap::setInitFont(Font *value)
|
||||
{
|
||||
void Bitmap::setInitFont(Font *value){
|
||||
p->font = value;
|
||||
}
|
||||
|
||||
TEXFBO &Bitmap::getGLTypes()
|
||||
{
|
||||
TEXFBO &Bitmap::getGLTypes(){
|
||||
return p->gl;
|
||||
}
|
||||
|
||||
SDL_Surface *Bitmap::megaSurface() const
|
||||
{
|
||||
SDL_Surface *Bitmap::megaSurface() const{
|
||||
return p->megaSurface;
|
||||
}
|
||||
|
||||
void Bitmap::ensureNonMega() const
|
||||
{
|
||||
void Bitmap::ensureNonMega() const{
|
||||
if (isDisposed())
|
||||
return;
|
||||
|
||||
GUARD_MEGA;
|
||||
}
|
||||
|
||||
void Bitmap::bindTex(ShaderBase &shader)
|
||||
{
|
||||
void Bitmap::bindTex(ShaderBase &shader){
|
||||
p->bindTexture(shader);
|
||||
}
|
||||
|
||||
void Bitmap::taintArea(const IntRect &rect)
|
||||
{
|
||||
void Bitmap::taintArea(const IntRect &rect){
|
||||
p->addTaintedArea(rect);
|
||||
}
|
||||
|
||||
void Bitmap::releaseResources()
|
||||
{
|
||||
void Bitmap::releaseResources(){
|
||||
if (p->megaSurface)
|
||||
SDL_DestroySurface(p->megaSurface);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ void Config::read(int argc, char *argv[]){
|
|||
PO_DESC(debugMode, bool, false) \
|
||||
PO_DESC(screenMode, bool, false) \
|
||||
PO_DESC(printFPS, bool, false) \
|
||||
PO_DESC(EnableSixteenByNine, bool, false) \
|
||||
PO_DESC(fullscreen, bool, false) \
|
||||
PO_DESC(fixedAspectRatio, bool, true) \
|
||||
PO_DESC(smoothScaling, bool, true) \
|
||||
|
|
@ -170,9 +171,15 @@ void Config::read(int argc, char *argv[]){
|
|||
rgssVersion = 1;
|
||||
game.title = "OneShot: Sunshine";
|
||||
game.scripts = "Data/xScripts.rxdata";
|
||||
defScreenW = 640;
|
||||
defScreenH = 480;
|
||||
|
||||
if (EnableSixteenByNine){
|
||||
defScreenW = 1280;
|
||||
defScreenH = 720;
|
||||
}else{
|
||||
defScreenW = 640;
|
||||
defScreenH = 480;
|
||||
}
|
||||
|
||||
#ifdef STEAM
|
||||
/* Override fullscreen config if Big Picture */
|
||||
if (const char *env = std::getenv("SteamTenfoot")){
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ struct Config{
|
|||
bool debugMode;
|
||||
bool screenMode;
|
||||
bool printFPS;
|
||||
|
||||
|
||||
bool fullscreen;
|
||||
bool fixedAspectRatio;
|
||||
bool smoothScaling;
|
||||
bool vsync;
|
||||
|
||||
bool EnableSixteenByNine;
|
||||
int defScreenW;
|
||||
int defScreenH;
|
||||
std::string windowTitle;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
#include <SDL3/SDL_surface.h>
|
||||
|
||||
namespace GLMeta
|
||||
{
|
||||
namespace GLMeta{
|
||||
|
||||
/* EXT_unpack_subimage */
|
||||
void subRectImageUpload(GLint srcW, GLint srcX, GLint srcY,
|
||||
|
|
@ -38,8 +37,7 @@ void subRectImageUpload(GLint srcW, GLint srcX, GLint srcY,
|
|||
void subRectImageEnd();
|
||||
|
||||
/* ARB_vertex_array_object */
|
||||
struct VAO
|
||||
{
|
||||
struct VAO{
|
||||
/* Set manually, then call vaoInit() */
|
||||
const VertexAttribute *attr;
|
||||
size_t attrCount;
|
||||
|
|
@ -52,8 +50,7 @@ struct VAO
|
|||
};
|
||||
|
||||
template<class VertexType>
|
||||
inline void vaoFillInVertexData(VAO &vao)
|
||||
{
|
||||
inline void vaoFillInVertexData(VAO &vao){
|
||||
vao.attr = VertexTraits<VertexType>::attr;
|
||||
vao.attrCount = VertexTraits<VertexType>::attrCount;
|
||||
vao.vertSize = sizeof(VertexType);
|
||||
|
|
|
|||
|
|
@ -27,23 +27,19 @@
|
|||
|
||||
#include <SDL3/SDL_rect.h>
|
||||
|
||||
static void applyBool(GLenum state, bool mode)
|
||||
{
|
||||
static void applyBool(GLenum state, bool mode){
|
||||
mode ? gl.Enable(state) : gl.Disable(state);
|
||||
}
|
||||
|
||||
void GLClearColor::apply(const Vec4 &value)
|
||||
{
|
||||
void GLClearColor::apply(const Vec4 &value){
|
||||
gl.ClearColor(value.x, value.y, value.z, value.w);
|
||||
}
|
||||
|
||||
void GLScissorBox::apply(const IntRect &value)
|
||||
{
|
||||
void GLScissorBox::apply(const IntRect &value){
|
||||
gl.Scissor(value.x, value.y, value.w, value.h);
|
||||
}
|
||||
|
||||
void GLScissorBox::setIntersect(const IntRect &value)
|
||||
{
|
||||
void GLScissorBox::setIntersect(const IntRect &value){
|
||||
const IntRect ¤t = get();
|
||||
|
||||
SDL_Rect r1 = { current.x, current.y, current.w, current.h };
|
||||
|
|
@ -56,13 +52,11 @@ void GLScissorBox::setIntersect(const IntRect &value)
|
|||
set(IntRect(result.x, result.y, result.w, result.h));
|
||||
}
|
||||
|
||||
void GLScissorTest::apply(const bool &value)
|
||||
{
|
||||
void GLScissorTest::apply(const bool &value){
|
||||
applyBool(GL_SCISSOR_TEST, value);
|
||||
}
|
||||
|
||||
void GLBlendMode::apply(const BlendType &value)
|
||||
{
|
||||
void GLBlendMode::apply(const BlendType &value){
|
||||
switch (value)
|
||||
{
|
||||
case BlendKeepDestAlpha :
|
||||
|
|
@ -92,28 +86,23 @@ void GLBlendMode::apply(const BlendType &value)
|
|||
}
|
||||
}
|
||||
|
||||
void GLBlend::apply(const bool &value)
|
||||
{
|
||||
void GLBlend::apply(const bool &value){
|
||||
applyBool(GL_BLEND, value);
|
||||
}
|
||||
|
||||
void GLViewport::apply(const IntRect &value)
|
||||
{
|
||||
void GLViewport::apply(const IntRect &value){
|
||||
gl.Viewport(value.x, value.y, value.w, value.h);
|
||||
}
|
||||
|
||||
void GLProgram::apply(const unsigned int &value)
|
||||
{
|
||||
void GLProgram::apply(const unsigned int &value){
|
||||
gl.UseProgram(value);
|
||||
}
|
||||
|
||||
GLState::Caps::Caps()
|
||||
{
|
||||
GLState::Caps::Caps(){
|
||||
gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
|
||||
}
|
||||
|
||||
GLState::GLState(const Config &conf)
|
||||
{
|
||||
GLState::GLState(const Config &conf){
|
||||
gl.Disable(GL_DEPTH_TEST);
|
||||
|
||||
clearColor.init(Vec4(0, 0, 0, 1));
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@
|
|||
#include <errno.h>
|
||||
#include <algorithm>
|
||||
|
||||
#define DEF_SCREEN_W (rgssVer == 1 ? 640 : 544)
|
||||
#define DEF_SCREEN_H (rgssVer == 1 ? 480 : 416)
|
||||
#define DEF_FRAMERATE (rgssVer == 1 ? 40 : 60)
|
||||
#define DEF_SCREEN_W (EnableSixteenByNine == 1 ? 640 : 544)
|
||||
#define DEF_SCREEN_H (EnableSixteenByNine == 1 ? 480 : 416)
|
||||
#define DEF_FRAMERATE (60)
|
||||
|
||||
#if defined _WIN32
|
||||
#define OS_W32
|
||||
|
|
@ -129,8 +129,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
class ScreenScene : public Scene
|
||||
{
|
||||
class ScreenScene : public Scene{
|
||||
public:
|
||||
ScreenScene(int width, int height)
|
||||
: pp(width, height)
|
||||
|
|
@ -459,7 +458,7 @@ struct GraphicsPrivate{
|
|||
TEX::ID obscuredTex;
|
||||
|
||||
GraphicsPrivate(RGSSThreadData *rtData)
|
||||
: scRes(DEF_SCREEN_W, DEF_SCREEN_H),
|
||||
: scRes(rtData->config.defScreenW, rtData->config.defScreenH),
|
||||
scSize(scRes),
|
||||
winSize(rtData->config.defScreenW, rtData->config.defScreenH),
|
||||
screen(scRes.x, scRes.y),
|
||||
|
|
@ -487,7 +486,7 @@ struct GraphicsPrivate{
|
|||
TEX::bind(obscuredTex);
|
||||
TEX::setRepeat(false);
|
||||
TEX::setSmooth(false);
|
||||
gl.TexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, 640, 480, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0);
|
||||
gl.TexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, scRes.x, scRes.y, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0);
|
||||
}
|
||||
|
||||
~GraphicsPrivate(){
|
||||
|
|
@ -575,7 +574,7 @@ struct GraphicsPrivate{
|
|||
void redrawScreen(){
|
||||
if (shState->oneshot().obscuredDirty){
|
||||
TEX::bind(obscuredTex);
|
||||
TEX::uploadSubImage(0, 0, 640, 480, shState->oneshot().obscuredMap().data(), GL_LUMINANCE);
|
||||
TEX::uploadSubImage(0, 0, scRes.x, scRes.y, shState->oneshot().obscuredMap().data(), GL_LUMINANCE);
|
||||
shState->oneshot().obscuredDirty = false;
|
||||
}
|
||||
screen.composite();
|
||||
|
|
@ -875,8 +874,8 @@ int Graphics::height() const{
|
|||
}
|
||||
|
||||
void Graphics::resizeScreen(int width, int height){
|
||||
width = clamp(width, 1, 640);
|
||||
height = clamp(height, 1, 480);
|
||||
width = clamp(width, 1, p->scRes.x);
|
||||
height = clamp(height, 1, p->scRes.y);
|
||||
|
||||
Vec2i size(width, height);
|
||||
|
||||
|
|
|
|||
|
|
@ -305,7 +305,6 @@ int main(int argc, char *argv[]){
|
|||
// winFlags |= SDL_WINDOW_RESIZABLE;
|
||||
// #endif
|
||||
|
||||
|
||||
win = SDL_CreateWindow(conf.windowTitle.c_str(), conf.defScreenW, conf.defScreenH, winFlags);
|
||||
if (conf.fullscreen)
|
||||
SDL_SetWindowFullscreen(win, true);
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@
|
|||
#include "debugwriter.h"
|
||||
#include "bitmap.h"
|
||||
#include "font.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
|
||||
// OS-Specific code
|
||||
#if defined _WIN32
|
||||
#define OS_W32
|
||||
|
|
@ -41,6 +43,7 @@
|
|||
#error "Operating system not detected or unsupported."
|
||||
#endif
|
||||
|
||||
|
||||
#define DEF_SCREEN_W 640
|
||||
#define DEF_SCREEN_H 480
|
||||
|
||||
|
|
@ -130,6 +133,9 @@ static int linux_dialog(void *rawData){
|
|||
gtk_main_quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#elif defined OS_W32
|
||||
/* Convert WCHAR pointer to std::string */
|
||||
static std::string w32_fromWide(const WCHAR *ustr){
|
||||
|
|
@ -167,7 +173,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
|||
p = new OneshotPrivate();
|
||||
p->window = threadData.window;
|
||||
p->savePath = threadData.config.commonDataPath.substr(0, threadData.config.commonDataPath.size() - 1);
|
||||
p->obscuredMap.resize(640 * 480, 255);
|
||||
p->obscuredMap.resize(threadData.config.defScreenW * threadData.config.defScreenH, 255);
|
||||
obscuredDirty = true;
|
||||
p->winX = 0;
|
||||
p->winY = 0;
|
||||
|
|
@ -459,7 +465,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){
|
|||
title = "";
|
||||
#ifdef OS_LINUX
|
||||
linux_DialogData data = {type, body, title, 0};
|
||||
gdk_threads_add_idle(linux_dialog, &data);
|
||||
g_idle_add(linux_dialog, &data);
|
||||
gtk_main();
|
||||
return data.result;
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in a new issue