mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
some fixes
This commit is contained in:
parent
b622b5dcdf
commit
cd44b13572
7 changed files with 73 additions and 6 deletions
|
|
@ -128,7 +128,6 @@ void audioBindingInit(){
|
||||||
rb_define_singleton_method(module, "play_tag_sounds", RUBY_METHOD_FUNC(rb_audio_playTagSounds), 1);
|
rb_define_singleton_method(module, "play_tag_sounds", RUBY_METHOD_FUNC(rb_audio_playTagSounds), 1);
|
||||||
rb_define_singleton_method(module, "stop_tag_sounds", RUBY_METHOD_FUNC(rb_audio_stopTagSounds), -1);
|
rb_define_singleton_method(module, "stop_tag_sounds", RUBY_METHOD_FUNC(rb_audio_stopTagSounds), -1);
|
||||||
|
|
||||||
|
|
||||||
rb_define_singleton_method(module, "unload", RUBY_METHOD_FUNC(rb_audio_unload), 1);
|
rb_define_singleton_method(module, "unload", RUBY_METHOD_FUNC(rb_audio_unload), 1);
|
||||||
rb_define_singleton_method(module, "clear_cache", RUBY_METHOD_FUNC(rb_audio_clearCache), 0);
|
rb_define_singleton_method(module, "clear_cache", RUBY_METHOD_FUNC(rb_audio_clearCache), 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,11 @@ static VALUE rb_playbackGetGroup(VALUE self){
|
||||||
return INT2FIX(pb->getGroup());
|
return INT2FIX(pb->getGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE rb_audio_getPath(VALUE self) {
|
||||||
|
PLAYBACK
|
||||||
|
return rb_utf8_str_new_cstr(pb->getPath().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE rb_playbackSetLoops(VALUE self, VALUE loops){
|
static VALUE rb_playbackSetLoops(VALUE self, VALUE loops){
|
||||||
PLAYBACK
|
PLAYBACK
|
||||||
pb->setLoops(NUM2INT(loops));
|
pb->setLoops(NUM2INT(loops));
|
||||||
|
|
@ -191,6 +196,8 @@ void audioPlaybackBindingInit(){
|
||||||
rb_define_method(audioplayback_klass, "group=", RUBY_METHOD_FUNC(rb_playbackSetGroup), 1);
|
rb_define_method(audioplayback_klass, "group=", RUBY_METHOD_FUNC(rb_playbackSetGroup), 1);
|
||||||
rb_define_method(audioplayback_klass, "group", RUBY_METHOD_FUNC(rb_playbackGetGroup), 0);
|
rb_define_method(audioplayback_klass, "group", RUBY_METHOD_FUNC(rb_playbackGetGroup), 0);
|
||||||
|
|
||||||
|
rb_define_method(audioplayback_klass, "path", RUBY_METHOD_FUNC(rb_audio_getPath), 0);
|
||||||
|
|
||||||
rb_define_method(audioplayback_klass, "loops=", RUBY_METHOD_FUNC(rb_playbackSetLoops), 1);
|
rb_define_method(audioplayback_klass, "loops=", RUBY_METHOD_FUNC(rb_playbackSetLoops), 1);
|
||||||
rb_define_method(audioplayback_klass, "loops", RUBY_METHOD_FUNC(rb_playbackGetLoops), 0);
|
rb_define_method(audioplayback_klass, "loops", RUBY_METHOD_FUNC(rb_playbackGetLoops), 0);
|
||||||
rb_define_method(audioplayback_klass, "volume=", RUBY_METHOD_FUNC(rb_playbackSetVolume), 1);
|
rb_define_method(audioplayback_klass, "volume=", RUBY_METHOD_FUNC(rb_playbackSetVolume), 1);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ module Audio
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def bgm_play(path, volume = 100, pitch = 100)
|
def bgm_play(path, volume = 100, pitch = 100)
|
||||||
|
if (@bgm_playback && @bgm_playback.path == path)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
bgm_stop
|
bgm_stop
|
||||||
@bgm_pos = 0
|
@bgm_pos = 0
|
||||||
@bgm_playback = self.create_sound(path, false, @music_group)
|
@bgm_playback = self.create_sound(path, false, @music_group)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
#==============================================================================
|
||||||
|
# ** Scene_Title
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# This class performs title screen processing.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
|
class Scene_Title
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------
|
||||||
|
# * Main Processing
|
||||||
|
#--------------------------------------------------------------------------
|
||||||
|
def main
|
||||||
|
|
||||||
|
# Stop playing ME and BGS
|
||||||
|
Audio.me_stop
|
||||||
|
Audio.bgs_stop
|
||||||
|
|
||||||
|
# Execute transition
|
||||||
|
Graphics.transition(40)
|
||||||
|
# Main loop
|
||||||
|
while true
|
||||||
|
# Update game screen
|
||||||
|
Graphics.update
|
||||||
|
# Update input information
|
||||||
|
Input.update
|
||||||
|
# only for legacy funcs
|
||||||
|
Audio.update
|
||||||
|
# Frame update
|
||||||
|
update
|
||||||
|
# Abort loop if screen is changed
|
||||||
|
if $scene != self
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -147,8 +147,9 @@ void EventThread::process(RGSSThreadData &rtData){
|
||||||
SDL_GetWindowPosition(win, &rtData.ethread->winX, &rtData.ethread->winY);
|
SDL_GetWindowPosition(win, &rtData.ethread->winX, &rtData.ethread->winY);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (shState != nullptr)
|
// TODO: fix main dispatcher segfault
|
||||||
shState->mainDispatcher().process();
|
//if (shState != nullptr)
|
||||||
|
// shState->mainDispatcher().process();
|
||||||
|
|
||||||
if (!SDL_WaitEvent(&event)) {
|
if (!SDL_WaitEvent(&event)) {
|
||||||
Debug() << "[EventThread::process] Event error: " << SDL_GetError();
|
Debug() << "[EventThread::process] Event error: " << SDL_GetError();
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,12 @@ int AudioPlayback::getGroup() const {
|
||||||
return p_group->id;
|
return p_group->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& AudioPlayback::getPath() const{
|
||||||
|
if (p_source)
|
||||||
|
return p_source->getPath();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
MIX_Track* AudioPlayback::getTrack() const {
|
MIX_Track* AudioPlayback::getTrack() const {
|
||||||
return p_track;
|
return p_track;
|
||||||
}
|
}
|
||||||
|
|
@ -224,9 +230,18 @@ bool AudioPlayback::fadeIn(double time, int loops) {
|
||||||
if (!p_track || !p_source)
|
if (!p_track || !p_source)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MIX_SetTrackLoops(p_track, loops);
|
bool result = MIX_SetTrackAudio(p_track, p_source->getAudio());
|
||||||
|
|
||||||
return fadeIn(time);
|
SDL_PropertiesID props = SDL_CreateProperties();
|
||||||
|
SDL_SetNumberProperty(props, MIX_PROP_PLAY_FADE_IN_MILLISECONDS_NUMBER, time * 1000.0);
|
||||||
|
SDL_SetNumberProperty(props, MIX_PROP_PLAY_LOOPS_NUMBER, loops);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
result = MIX_PlayTrack(p_track, props);
|
||||||
|
}
|
||||||
|
SDL_DestroyProperties(props);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioPlayback::fadeIn(double time) {
|
bool AudioPlayback::fadeIn(double time) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "audiogroup.h"
|
#include "audiogroup.h"
|
||||||
#include "audiosource.h"
|
#include "audiosource.h"
|
||||||
|
|
||||||
constexpr float DEFAULT_FADE_IN = 0.001f; // no more clicks ;lskadfjjkfskljgsf
|
constexpr float DEFAULT_FADE_IN = 0.0f;
|
||||||
|
|
||||||
class AudioPlayback
|
class AudioPlayback
|
||||||
{
|
{
|
||||||
|
|
@ -33,6 +33,7 @@ public:
|
||||||
void setGroup(int group);
|
void setGroup(int group);
|
||||||
int getGroup() const;
|
int getGroup() const;
|
||||||
MIX_Track* getTrack() const;
|
MIX_Track* getTrack() const;
|
||||||
|
const std::string& getPath() const;
|
||||||
|
|
||||||
void setLoops(int loops);
|
void setLoops(int loops);
|
||||||
int getLoops() const;
|
int getLoops() const;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue