Merge branch 'master' of ssh://code.nikooneshot.ru:222/Sunshine/mkxp-sunshine

This commit is contained in:
DepressedTWM 2026-08-14 21:06:09 +04:00
commit f53e09f331
8 changed files with 103 additions and 34 deletions

View file

@ -78,6 +78,9 @@ DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, "tone")
DEF_PROP_I(Viewport, OX)
DEF_PROP_I(Viewport, OY)
DEF_PROP_F(Viewport, ScaleX)
DEF_PROP_F(Viewport, ScaleY)
void viewportBindingInit(){
VALUE klass = rb_define_class("Viewport", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&ViewportType>);
@ -88,10 +91,12 @@ void viewportBindingInit(){
_rb_define_method(klass, "initialize", viewportInitialize);
INIT_PROP_BIND( Viewport, Rect, "rect" );
INIT_PROP_BIND( Viewport, OX, "ox" );
INIT_PROP_BIND( Viewport, OY, "oy" );
INIT_PROP_BIND( Viewport, Color, "color" );
INIT_PROP_BIND( Viewport, Tone, "tone" );
INIT_PROP_BIND( Viewport, Rect, "rect" );
INIT_PROP_BIND( Viewport, OX, "ox" );
INIT_PROP_BIND( Viewport, OY, "oy" );
INIT_PROP_BIND( Viewport, ScaleX, "scale_x");
INIT_PROP_BIND( Viewport, ScaleY, "scale_y");
INIT_PROP_BIND( Viewport, Color, "color" );
INIT_PROP_BIND( Viewport, Tone, "tone" );
}

View file

@ -56,4 +56,5 @@ Added Crash Screen
Added In-Memory Log buffer
Added setting "Use Old Self Contained Universe(Reprise) version"
Rewrited audio system from SDL3_sound and OpenAL to SDL_mixer
Added Master Volume setting
Added Master Volume setting
Added viewports scaling

View file

@ -55,7 +55,9 @@ module Audio
@bgs_playback.play(-1, volume / 100.0, pitch / 100.0)
end
def bgs_fade(time)
@bgs_playback.fade_out(time / 60.0)
if (@bgs_playback && @bgs_playback.playing)
@bgs_playback.fade_out(time / 60.0)
end
end
def bgs_stop
if @bgs_playback
@ -79,10 +81,12 @@ module Audio
@me_playback.play(0, volume / 100.0, pitch / 100.0)
end
def me_fade(time)
@me_playback.fade_out(time / 60.0)
if @bgm_playback
@bgm_playback.position = @bgm_pos
@bgm_playback.fade_in(time / 60.0)
if (@me_playback && @me_playback.playing)
@me_playback.fade_out(time / 60.0)
if @bgm_playback
@bgm_playback.position = @bgm_pos
@bgm_playback.fade_in(time / 60.0)
end
end
end
def me_stop

View file

@ -1,4 +1,10 @@
class Scene_OF
BPM = 135
WAIT_TIME = 1.0 * (BPM / 60.0) * Graphics.frame_rate
BUMP_SCALE = 1.2
BUMP_RETURN_SPEED = 0.2
ARROW_SIZE = 32
ARROW_SCALE = 2
ARROWS_PADDING = 12
@ -55,29 +61,33 @@ class Scene_OF
def main
Audio.bgm_stop
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport_ui = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport_ui.ox = -Graphics.width / 2
@viewport_ui.oy = -Graphics.height / 2
@spritesheet = RPG::Cache.misc(".cats")
@player_arrows = []
@cat_arrows = []
for i in 0..3
player_arrow = Sprite.new(@viewport)
player_arrow = Sprite.new(@viewport_ui)
player_arrow.bitmap = Bitmap.new(ARROW_SIZE, ARROW_SIZE)
player_arrow.bitmap.stretch_blt(Rect.new(0, 0, ARROW_SIZE, ARROW_SIZE), @spritesheet, SPRITES[PLAYER_ARROWS_SPRITES[:base][i]])
player_arrow.zoom_x = player_arrow.zoom_y = ARROW_SCALE
player_arrow.x = Graphics.width - ARROWS_SIDES_MARGIN + (ARROW_SIZE * ARROW_SCALE + ARROWS_PADDING) * i - (ARROW_SIZE * ARROW_SCALE * 4 + ARROWS_PADDING * 3)
player_arrow.y = ARROWS_TOP_MARGIN
player_arrow.x = Graphics.width / 2 - ARROWS_SIDES_MARGIN + (ARROW_SIZE * ARROW_SCALE + ARROWS_PADDING) * i - (ARROW_SIZE * ARROW_SCALE * 4 + ARROWS_PADDING * 3)
player_arrow.y = ARROWS_TOP_MARGIN - Graphics.height / 2
@player_arrows << player_arrow
cat_arrow = Sprite.new(@viewport)
cat_arrow = Sprite.new(@viewport_ui)
cat_arrow.bitmap = Bitmap.new(ARROW_SIZE, ARROW_SIZE)
cat_arrow.bitmap.stretch_blt(Rect.new(0, 0, ARROW_SIZE, ARROW_SIZE), @spritesheet, SPRITES[CAT_ARROWS_SPRITES[:base][i]])
cat_arrow.zoom_x = cat_arrow.zoom_y = ARROW_SCALE
cat_arrow.x = ARROWS_SIDES_MARGIN + (ARROW_SIZE * ARROW_SCALE + ARROWS_PADDING) * i
cat_arrow.y = ARROWS_TOP_MARGIN
cat_arrow.x = ARROWS_SIDES_MARGIN + (ARROW_SIZE * ARROW_SCALE + ARROWS_PADDING) * i - Graphics.width / 2
cat_arrow.y = ARROWS_TOP_MARGIN - Graphics.height / 2
@cat_arrows << cat_arrow
end
@bump_timeout = WAIT_TIME
# Execute transition
Graphics.transition(40)
# Main loop
@ -99,7 +109,14 @@ class Scene_OF
end
def update
@viewport.scale_x -= 0.001
@bump_timeout -= 1
if @bump_timeout <= 0
@bump_timeout += WAIT_TIME
@viewport_ui.scale_x = BUMP_SCALE
@viewport_ui.scale_y = BUMP_SCALE
end
@viewport_ui.scale_x = @viewport_ui.scale_x * (1.0 - BUMP_RETURN_SPEED) + BUMP_RETURN_SPEED
@viewport_ui.scale_y = @viewport_ui.scale_y * (1.0 - BUMP_RETURN_SPEED) + BUMP_RETURN_SPEED
end
def map_input(input)

View file

@ -622,6 +622,11 @@ void Sprite::onGeometryChange(const Scene::Geometry &geo){
/* Offset at which the sprite will be drawn
* relative to screen origin */
p->trans.setGlobalOffset(geo.offset());
Viewport* viewport = ViewportElement::getViewport();
if (viewport)
p->trans.setGlobalScale(Vec2(viewport->getScaleX(), viewport->getScaleY()));
else
p->trans.setGlobalScale(Vec2(1.0, 1.0));
p->sceneRect.setSize(geo.rect.size());
p->sceneOrig = geo.orig;

View file

@ -103,6 +103,11 @@ public:
dirty = true;
}
void setGlobalScale(const Vec2 &value){
globalScale = value;
dirty = true;
}
const float *getMatrix(){
if (dirty){
updateMatrix();
@ -121,18 +126,18 @@ private:
float angle = rotation * 3.141592654f / 180.0f;
float cosine = (float) SDL_cos(angle);
float sine = (float) sin(angle);
float sine = (float) SDL_sin(angle);
float sxc = scale.x * cosine;
float syc = scale.y * cosine;
float sxs = scale.x * sine;
float sys = scale.y * sine;
float tx = -origin.x * sxc - origin.y * sys + position.x + offset.x;
float ty = origin.x * sxs - origin.y * syc + position.y + offset.y;
float tx = (-origin.x * sxc - origin.y * sys + position.x) * globalScale.x + offset.x;
float ty = ( origin.x * sxs - origin.y * syc + position.y) * globalScale.y + offset.y;
matrix[0] = sxc;
matrix[1] = -sxs;
matrix[4] = sys;
matrix[5] = syc;
matrix[0] = sxc * globalScale.x;
matrix[1] = -sxs * globalScale.y;
matrix[4] = sys * globalScale.x;
matrix[5] = syc * globalScale.y;
matrix[12] = tx;
matrix[13] = ty;
}
@ -144,6 +149,8 @@ private:
/* Silently added to position */
Vec2i offset;
/* Silently added to scale */
Vec2 globalScale;
float matrix[16];

View file

@ -44,6 +44,9 @@ struct ViewportPrivate{
IntRect screenRect;
int isOnScreen;
double scaleX;
double scaleY;
EtcTemps tmp;
ViewportPrivate(int x, int y, unsigned int width, unsigned int height, Viewport *self)
@ -51,6 +54,8 @@ struct ViewportPrivate{
rect(&tmp.rect),
color(&tmp.color),
tone(&tmp.tone),
scaleX(1.0),
scaleY(1.0),
isOnScreen(false)
{
rect->set(x, y, width, height);
@ -61,7 +66,7 @@ struct ViewportPrivate{
rectCon.Disconnect();
}
void onRectChange(){
void onRectChange() {
self->geometry.rect = rect->toIntRect();
self->notifyGeometryChange();
recomputeOnScreen();
@ -131,8 +136,11 @@ void Viewport::update(){
Flashable::update();
}
DEF_ATTR_RD_SIMPLE(Viewport, OX, int, geometry.orig.x)
DEF_ATTR_RD_SIMPLE(Viewport, OY, int, geometry.orig.y)
DEF_ATTR_RD_SIMPLE(Viewport, OX, int, geometry.orig.x)
DEF_ATTR_RD_SIMPLE(Viewport, OY, int, geometry.orig.y)
DEF_ATTR_RD_SIMPLE(Viewport, ScaleX, double, p->scaleX)
DEF_ATTR_RD_SIMPLE(Viewport, ScaleY, double, p->scaleY)
DEF_ATTR_SIMPLE(Viewport, Rect, Rect&, *p->rect)
DEF_ATTR_SIMPLE(Viewport, Color, Color&, *p->color)
@ -158,6 +166,26 @@ void Viewport::setOY(int value){
notifyGeometryChange();
}
void Viewport::setScaleX(double value){
guardDisposed();
if (p->scaleX == value)
return;
p->scaleX = value;
notifyGeometryChange();
}
void Viewport::setScaleY(double value){
guardDisposed();
if (p->scaleY == value)
return;
p->scaleY = value;
notifyGeometryChange();
}
void Viewport::initDynAttribs(){
p->rect = new Rect(*p->rect);
p->color = new Color;

View file

@ -38,11 +38,13 @@ public:
void update();
DECL_ATTR( Rect, Rect& )
DECL_ATTR( OX, int )
DECL_ATTR( OY, int )
DECL_ATTR( Color, Color& )
DECL_ATTR( Tone, Tone& )
DECL_ATTR( Rect, Rect& )
DECL_ATTR( OX, int )
DECL_ATTR( OY, int )
DECL_ATTR( ScaleX, double )
DECL_ATTR( ScaleY, double )
DECL_ATTR( Color, Color& )
DECL_ATTR( Tone, Tone& )
void initDynAttribs();