VERSIÓ 1.3.7
- [NEW] music.enable() i sound.enable()
This commit is contained in:
@@ -308,6 +308,10 @@ void JA_EnableMusic(const bool value)
|
||||
JA_musicEnabled = value;
|
||||
}
|
||||
|
||||
const bool JA_IsMusicEnabled()
|
||||
{
|
||||
return JA_musicEnabled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -488,6 +492,11 @@ void JA_EnableSound(const bool value)
|
||||
JA_soundEnabled = value;
|
||||
}
|
||||
|
||||
const bool JA_IsSoundEnabled()
|
||||
{
|
||||
return JA_soundEnabled;
|
||||
}
|
||||
|
||||
float JA_SetVolume(float volume)
|
||||
{
|
||||
JA_SetSoundVolume(JA_SetMusicVolume(volume) / 2.0f);
|
||||
|
||||
@@ -23,6 +23,7 @@ float JA_SetMusicVolume(float volume);
|
||||
void JA_SetMusicPosition(float value);
|
||||
float JA_GetMusicPosition();
|
||||
void JA_EnableMusic(const bool value);
|
||||
const bool JA_IsMusicEnabled();
|
||||
|
||||
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length);
|
||||
JA_Sound_t *JA_LoadSound(Uint8* buffer, Uint32 length);
|
||||
@@ -36,5 +37,6 @@ JA_Channel_state JA_GetChannelState(const int channel);
|
||||
void JA_DeleteSound(JA_Sound_t *sound);
|
||||
float JA_SetSoundVolume(float volume);
|
||||
void JA_EnableSound(const bool value);
|
||||
const bool JA_IsSoundEnabled();
|
||||
|
||||
float JA_SetVolume(float volume);
|
||||
|
||||
22
lua.cpp
22
lua.cpp
@@ -584,6 +584,16 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_music_enable(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushboolean(L, ismusicenabled());
|
||||
return 1;
|
||||
} else {
|
||||
enablemusic(lua_toboolean(L, 1));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sound
|
||||
// ===============================================
|
||||
@@ -613,6 +623,16 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cpp_sound_enable(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushboolean(L, issoundenabled());
|
||||
return 1;
|
||||
} else {
|
||||
enablesound(lua_toboolean(L, 1));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sys
|
||||
// ===============================================
|
||||
@@ -913,6 +933,7 @@ void push_lua_funcs() {
|
||||
lua_pushcfunction(L,cpp_music_resume); lua_setfield(L, -2, "resume");
|
||||
lua_pushcfunction(L,cpp_music_stop); lua_setfield(L, -2, "stop");
|
||||
lua_pushcfunction(L,cpp_music_pos); lua_setfield(L, -2, "pos");
|
||||
lua_pushcfunction(L,cpp_music_enable); lua_setfield(L, -2, "enabled");
|
||||
lua_setglobal(L, "music");
|
||||
|
||||
lua_newtable(L);
|
||||
@@ -920,6 +941,7 @@ void push_lua_funcs() {
|
||||
lua_pushcfunction(L,cpp_sound_free); lua_setfield(L, -2, "free");
|
||||
lua_pushcfunction(L,cpp_sound_play); lua_setfield(L, -2, "play");
|
||||
lua_pushcfunction(L,cpp_sound_stop); lua_setfield(L, -2, "stop");
|
||||
lua_pushcfunction(L,cpp_sound_enable); lua_setfield(L, -2, "enabled");
|
||||
lua_setglobal(L, "sound");
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
27
mini.cpp
27
mini.cpp
@@ -410,6 +410,10 @@ int main(int argc,char*argv[]){
|
||||
if (fullscreen) screen_fullscreen=strcmp(fullscreen, "true")==0?true:false;
|
||||
const char *cursor = file_getconfigvalue("cursor");
|
||||
if (cursor) screen_cursor=strcmp(cursor, "true")?true:false;
|
||||
const char *music_enabled = file_getconfigvalue("music");
|
||||
if (music_enabled) JA_EnableMusic(strcmp(music_enabled, "true")==0?true:false);
|
||||
const char *sound_enabled = file_getconfigvalue("sound");
|
||||
if (sound_enabled) JA_EnableSound(strcmp(sound_enabled, "true")==0?true:false);
|
||||
}
|
||||
|
||||
setdest(newsurf(screen_width, screen_height));
|
||||
@@ -1255,6 +1259,18 @@ float musicpos()
|
||||
return JA_GetMusicPosition();
|
||||
}
|
||||
|
||||
void enablemusic(const bool value)
|
||||
{
|
||||
JA_EnableMusic(value);
|
||||
file_setconfigvalue("music", value?"true":"false");
|
||||
}
|
||||
|
||||
const bool ismusicenabled()
|
||||
{
|
||||
return JA_IsMusicEnabled();
|
||||
}
|
||||
|
||||
|
||||
int loadsound(const char *filename) {
|
||||
int size;
|
||||
char *buffer = file_getfilebuffer(filename, size);
|
||||
@@ -1282,6 +1298,17 @@ void stopsound(int soundchannel) {
|
||||
//Mix_HaltChannel(soundchannel);
|
||||
}
|
||||
|
||||
void enablesound(const bool value)
|
||||
{
|
||||
JA_EnableSound(value);
|
||||
file_setconfigvalue("sound", value?"true":"false");
|
||||
}
|
||||
|
||||
const bool issoundenabled()
|
||||
{
|
||||
return JA_IsSoundEnabled();
|
||||
}
|
||||
|
||||
int getzoom() {
|
||||
return screen_zoom;
|
||||
}
|
||||
|
||||
4
mini.h
4
mini.h
@@ -235,11 +235,15 @@ void resumemusic();
|
||||
void stopmusic(const int t=1000);
|
||||
void musicpos(float value);
|
||||
float musicpos();
|
||||
void enablemusic(const bool value);
|
||||
const bool ismusicenabled();
|
||||
|
||||
int loadsound(const char *filename);
|
||||
void freesound(int soundfile);
|
||||
int playsound(int soundfile, const int volume=-1);
|
||||
void stopsound(int soundchannel);
|
||||
void enablesound(const bool value);
|
||||
const bool issoundenabled();
|
||||
|
||||
int getzoom();
|
||||
void setzoom(const int value);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define MINI_VERSION "1.3.6"
|
||||
#define MINI_VERSION "1.3.7"
|
||||
|
||||
@@ -325,6 +325,15 @@ function music.pos() end
|
||||
---Set the playing position of the currently loaded song
|
||||
function music.pos(pos) end
|
||||
|
||||
---@return boolean value
|
||||
---Get if music is enabled
|
||||
function music.enabled() end
|
||||
|
||||
---@param value boolean
|
||||
---Set if music is enabled or not
|
||||
function music.enabled(value) end
|
||||
|
||||
|
||||
---@class sound
|
||||
sound = {}
|
||||
|
||||
@@ -352,6 +361,14 @@ function sound.play(snd, loop) end
|
||||
---Stop the channel specified
|
||||
function sound.stop(chl) end
|
||||
|
||||
---@return boolean value
|
||||
---Get if sound is enabled
|
||||
function sound.enabled() end
|
||||
|
||||
---@param value boolean
|
||||
---Set if sound is enabled or not
|
||||
function sound.enabled(value) end
|
||||
|
||||
---@class sys
|
||||
sys = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user