Skip to content

Commit

Permalink
Merge branch 'mkxp-z:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Speak2Erase authored Jul 31, 2024
2 parents fbe4ba3 + 03a91cf commit e44b826
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 14 deletions.
4 changes: 2 additions & 2 deletions mkxp.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@


// Allow symlinks for game assets to be followed
// (default: disabled)
// (default: enabled)
//
// "allowSymlinks": false,
// "allowSymlinks": true,


// Organisation / company and application / game
Expand Down
14 changes: 7 additions & 7 deletions scripts/preload/win32_wrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# all copyright and related or neighboring rights to win32_wrap.rb.
# https://creativecommons.org/publicdomain/zero/1.0/

# Edits by Splendide Imaginarius (2023) also CC0.
# Edits by Splendide Imaginarius (2023-2024) also CC0.

# This preload script provides a subset of Win32API in a cross-platform way, so
# you can play Win32API-based games on Linux and macOS.
Expand Down Expand Up @@ -183,17 +183,17 @@ def common_keystate(vkey)
states = get_raw_keystates
pressed = false

if vkey == :LBUTTON
if vkey_name == :LBUTTON
pressed = Input.press?(Input::MOUSELEFT)
elsif vkey == :RBUTTON
elsif vkey_name == :RBUTTON
pressed = Input.press?(Input::MOUSERIGHT)
elsif vkey == :MBUTTON
elsif vkey_name == :MBUTTON
pressed = Input.press?(Input::MOUSEMIDDLE)
elsif vkey == :SHIFT
elsif vkey_name == :SHIFT
pressed = double_state(states, :LSHIFT, :RSHIFT)
elsif vkey == :MENU
elsif vkey_name == :MENU
pressed = double_state(states, :LALT, :RALT)
elsif vkey == :CONTROL
elsif vkey_name == :CONTROL
pressed = double_state(states, :LCTRL, :RCTRL)
else
scan = nil
Expand Down
2 changes: 1 addition & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void Config::read(int argc, char *argv[]) {
{"anyAltToggleFS", false},
{"enableReset", true},
{"enableSettings", true},
{"allowSymlinks", false},
{"allowSymlinks", true},
{"dataPathOrg", ""},
{"dataPathApp", "OSFM"},
{"iconPath", ""},
Expand Down
9 changes: 9 additions & 0 deletions src/display/bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ Bitmap::Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires, bool forceMega)
Bitmap::~Bitmap()
{
dispose();

loresDispCon.disconnect();
}

void Bitmap::initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool forceMega)
Expand Down Expand Up @@ -927,6 +929,7 @@ void Bitmap::setLores(Bitmap *lores) {
guardDisposed();

p->selfLores = lores;
loresDispCon = lores->wasDisposed.connect(&Bitmap::loresDisposal, this);
}

bool Bitmap::isMega() const{
Expand Down Expand Up @@ -2635,3 +2638,9 @@ void Bitmap::releaseResources()

delete p;
}

void Bitmap::loresDisposal()
{
loresDispCon.disconnect();
dispose();
}
3 changes: 3 additions & 0 deletions src/display/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ class Bitmap : public Disposable

private:
void releaseResources();
sigslot::connection loresDispCon;
const char *klassName() const { return "bitmap"; }

BitmapPrivate *p;

void loresDisposal();
};

#endif // BITMAP_H
22 changes: 18 additions & 4 deletions src/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1449,15 +1449,29 @@ int Input::dir8Value()
int Input::mouseX()
{
RGSSThreadData &rtData = shState->rtData();

return (p->mousePos[0] - rtData.screenOffset.x) * rtData.sizeResoRatio.x;

int hiresResult = (p->mousePos[0] - rtData.screenOffset.x) * rtData.sizeResoRatio.x;

if (shState->config().enableHires) {
double framebufferScalingFactor = shState->config().framebufferScalingFactor;
return (int)lround(hiresResult / framebufferScalingFactor);
}

return hiresResult;
}

int Input::mouseY()
{
RGSSThreadData &rtData = shState->rtData();

return (p->mousePos[1] - rtData.screenOffset.y) * rtData.sizeResoRatio.y;

int hiresResult = (p->mousePos[1] - rtData.screenOffset.y) * rtData.sizeResoRatio.y;

if (shState->config().enableHires) {
double framebufferScalingFactor = shState->config().framebufferScalingFactor;
return (int)lround(hiresResult / framebufferScalingFactor);
}

return hiresResult;
}

int Input::scrollV()
Expand Down
19 changes: 19 additions & 0 deletions tests/hires-bitmap/hires-bitmap-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,25 @@ def dump(bmp, spr, desc)

# TODO: Animation tests, if we can find a good way to test them.

bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 100)
fnt.out_color = Color.new(0, 255, 0)
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "Now testing dispose for memory leaks...", 1)
dump(bmp, spr, "memory-leak")

def allocate()
bmp_allocate = Bitmap.new("Graphics/Pictures/children-alpha")
bmp_allocate.dispose
end

for i in (1...100)
for j in (1...10)
allocate
end
System::puts("Memory leak test #{i}/100")
end

# Tests are finished, show exit screen

bmp = Bitmap.new(640, 480)
Expand Down

0 comments on commit e44b826

Please sign in to comment.