A lot of changes with this rev

*Rewrote the whole Settings.cpp into 11 classes. Each settings menu has it's own class now
*Reworked the whole sound system. Supported formats AIF/MP3/OGG/BNS/WAV now with no file size limit (streaming).
*Changed button click/over sounds to wav from raw pcm
*Lot's of bug fixes
This commit is contained in:
dimok321 2010-11-13 22:34:53 +00:00
parent 45e15bdb0b
commit fa11a745d6
107 changed files with 8292 additions and 6722 deletions

View File

@ -33,6 +33,7 @@ SOURCES := source \
source/xml \
source/network \
source/settings \
source/settings/menus \
source/prompts \
source/wad \
source/banner \
@ -43,6 +44,7 @@ SOURCES := source \
source/memory \
source/FileOperations \
source/ImageOperations \
source/SoundOperations \
source/utils \
source/utils/minizip \
source/usbloader/wbfs
@ -53,7 +55,7 @@ INCLUDES := source
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O4 -Wall $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CFLAGS = -g -O4 -Wall -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CXXFLAGS = -Xassembler -aln=$@.lst $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80B00000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size
-include $(PROJECTDIR)/Make.config
@ -93,6 +95,7 @@ TTFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf)))
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg)))
PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm)))
WAVFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.wav)))
DOLFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.dol)))
MP3FILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.mp3)))
@ -110,7 +113,7 @@ export OFILES := $(addsuffix .o,$(BINFILES)) \
$(sFILES:.s=.o) $(SFILES:.S=.o) \
$(TTFFILES:.ttf=.ttf.o) $(PNGFILES:.png=.png.o) $(addsuffix .o,$(DOLFILES))\
$(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o) $(MP3FILES:.mp3=.mp3.o) \
$(addsuffix .o,$(ELFFILES)) $(CURDIR)/data/magic_patcher.o
$(WAVFILES:.wav=.wav.o) $(addsuffix .o,$(ELFFILES)) $(CURDIR)/data/magic_patcher.o
#---------------------------------------------------------------------------------
# build a list of include paths
@ -215,6 +218,10 @@ language: $(wildcard $(PROJECTDIR)/Languages/*.lang)
%.pcm.o : %.pcm
@echo $(notdir $<)
@bin2s -a 32 $< | $(AS) -o $(@)
%.wav.o : %.wav
@echo $(notdir $<)
@bin2s -a 32 $< | $(AS) -o $(@)
%.mp3.o : %.mp3
@echo $(notdir $<)

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\utils" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="false"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\libs" x="false"></e><e p="gui\source\menu" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\system" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\FileOperations" x="false"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e><e p="gui\source\ImageOperations" x="false"></e><e p="gui\source\memory" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e></ViewState></pd>
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\utils" x="false"></e><e p="gui\source\SoundOperations" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="false"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\libs" x="false"></e><e p="gui\source\menu" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\system" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\FileOperations" x="false"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e><e p="gui\source\ImageOperations" x="false"></e><e p="gui\source\memory" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e></ViewState></pd>

View File

@ -0,0 +1,145 @@
#include <cstring>
#include "File.hpp"
CFile::CFile()
{
file_fd = NULL;
mem_file = NULL;
filesize = 0;
Pos = 0;
}
CFile::CFile(const char * filepath, const char * mode)
{
file_fd = NULL;
open(filepath, mode);
}
CFile::CFile(const u8 * mem, int size)
{
file_fd = NULL;
open(mem, size);
}
CFile::~CFile()
{
close();
}
int CFile::open(const char * filepath, const char * mode)
{
close();
file_fd = fopen(filepath, mode);
if(!file_fd)
return -1;
fseek(file_fd, 0, SEEK_END);
filesize = ftell(file_fd);
rewind();
return 0;
}
int CFile::open(const u8 * mem, int size)
{
close();
mem_file = mem;
filesize = size;
return 0;
}
void CFile::close()
{
if(file_fd)
fclose(file_fd);
file_fd = NULL;
mem_file = NULL;
filesize = 0;
Pos = 0;
}
int CFile::read(u8 * ptr, size_t size)
{
if(file_fd)
{
int ret = fread(ptr, 1, size, file_fd);
if(ret > 0)
Pos += ret;
return ret;
}
int readsize = size;
if(readsize > (long int) filesize-Pos)
readsize = filesize-Pos;
if(readsize <= 0)
return readsize;
if(mem_file != NULL)
{
memcpy(ptr, mem_file+Pos, readsize);
Pos += readsize;
return readsize;
}
return -1;
}
int CFile::write(const u8 * ptr, size_t size)
{
if(size < 0)
return size;
if(file_fd)
{
int ret = fwrite(ptr, 1, size, file_fd);
if(ret > 0)
Pos += ret;
return ret;
}
return -1;
}
int CFile::seek(long int offset, int origin)
{
int ret = 0;
if(origin == SEEK_SET)
{
Pos = offset;
}
else if(origin == SEEK_CUR)
{
Pos += offset;
}
else if(origin == SEEK_END)
{
Pos = filesize+offset;
}
if(Pos < 0)
{
Pos = 0;
return -1;
}
if(file_fd)
ret = fseek(file_fd, Pos, SEEK_SET);
if(mem_file != NULL)
{
if(Pos > (long int) filesize)
{
Pos = filesize;
return -1;
}
}
return ret;
}

View File

@ -0,0 +1,30 @@
#ifndef FILE_HPP_
#define FILE_HPP_
#include <stdio.h>
#include <gctypes.h>
class CFile
{
public:
CFile();
CFile(const char * filepath, const char * mode);
CFile(const u8 * memory, int memsize);
~CFile();
int open(const char * filepath, const char * mode);
int open(const u8 * memory, int memsize);
void close();
int read(u8 * ptr, size_t size);
int write(const u8 * ptr, size_t size);
int seek(long int offset, int origin);
long int tell() { return Pos; };
long int size() { return filesize; };
void rewind() { seek(0, SEEK_SET); };
protected:
FILE * file_fd;
const u8 * mem_file;
u64 filesize;
long int Pos;
};
#endif

View File

@ -0,0 +1,214 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <string.h>
#include <math.h>
#include "AifDecoder.hpp"
typedef struct
{
u32 fccCOMM;
u32 size;
u16 channels;
u8 frames[4];
u16 bps;
u8 freq[10];
} SAIFFCommChunk;
typedef struct
{
u32 fccSSND;
u32 size;
u32 offset;
u32 blockSize;
} SAIFFSSndChunk;
// ------
// Copyright (C) 1988-1991 Apple Computer, Inc.
#ifndef HUGE_VAL
# define HUGE_VAL HUGE
#endif
# define UnsignedToFloat(u) (((double)((long)(u - 2147483647L - 1))) + 2147483648.0)
static double ConvertFromIeeeExtended(const unsigned char* bytes)
{
double f;
int expon;
unsigned long hiMant, loMant;
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
hiMant = ((unsigned long)(bytes[2] & 0xFF) << 24)
| ((unsigned long)(bytes[3] & 0xFF) << 16)
| ((unsigned long)(bytes[4] & 0xFF) << 8)
| ((unsigned long)(bytes[5] & 0xFF));
loMant = ((unsigned long)(bytes[6] & 0xFF) << 24)
| ((unsigned long)(bytes[7] & 0xFF) << 16)
| ((unsigned long)(bytes[8] & 0xFF) << 8)
| ((unsigned long)(bytes[9] & 0xFF));
if (expon == 0 && hiMant == 0 && loMant == 0) {
f = 0;
}
else {
if (expon == 0x7FFF) {
f = HUGE_VAL;
}
else {
expon -= 16383;
f = ldexp(UnsignedToFloat(hiMant), expon-=31);
f += ldexp(UnsignedToFloat(loMant), expon-=32);
}
}
if (bytes[0] & 0x80)
return -f;
else
return f;
}
AifDecoder::AifDecoder(const char * filepath)
: SoundDecoder(filepath)
{
SoundType = SOUND_AIF;
if(!file_fd)
return;
OpenFile();
}
AifDecoder::AifDecoder(const u8 * snd, int len)
: SoundDecoder(snd, len)
{
SoundType = SOUND_AIF;
if(!file_fd)
return;
OpenFile();
}
AifDecoder::~AifDecoder()
{
}
void AifDecoder::OpenFile()
{
SWaveHdr Header;
file_fd->read((u8 *) &Header, sizeof(SWaveHdr));
if (Header.magicRIFF != 'FORM')
{
CloseFile();
return;
}
else if(Header.magicWAVE != 'AIFF')
{
CloseFile();
return;
}
SWaveChunk WaveChunk;
do
{
int ret = file_fd->read((u8 *) &WaveChunk, sizeof(SWaveChunk));
if(ret <= 0)
{
CloseFile();
return;
}
}
while(WaveChunk.magicDATA != 'COMM');
DataOffset = file_fd->tell()+WaveChunk.size;
SAIFFCommChunk CommHdr;
file_fd->seek(file_fd->tell()-sizeof(SWaveChunk), SEEK_SET);
file_fd->read((u8 *) &CommHdr, sizeof(SAIFFCommChunk));
if(CommHdr.fccCOMM != 'COMM')
{
CloseFile();
return;
}
file_fd->seek(DataOffset, SEEK_SET);
SAIFFSSndChunk SSndChunk;
file_fd->read((u8 *) &SSndChunk, sizeof(SAIFFSSndChunk));
if(SSndChunk.fccSSND != 'SSND')
{
CloseFile();
return;
}
DataOffset += sizeof(SAIFFSSndChunk);
DataSize = SSndChunk.size-8;
SampleRate = (u32) ConvertFromIeeeExtended(CommHdr.freq);
Format = VOICE_STEREO_16BIT;
if(CommHdr.channels == 1 && CommHdr.bps == 8)
Format = VOICE_MONO_8BIT;
else if (CommHdr.channels == 1 && CommHdr.bps == 16)
Format = VOICE_MONO_16BIT;
else if (CommHdr.channels == 2 && CommHdr.bps == 8)
Format = VOICE_STEREO_8BIT;
else if (CommHdr.channels == 2 && CommHdr.bps == 16)
Format = VOICE_STEREO_16BIT;
Decode();
}
void AifDecoder::CloseFile()
{
if(file_fd)
delete file_fd;
file_fd = NULL;
}
int AifDecoder::Read(u8 * buffer, int buffer_size, int pos)
{
if(!file_fd)
return -1;
if(CurPos >= (int) DataSize)
return 0;
file_fd->seek(DataOffset+CurPos, SEEK_SET);
if(buffer_size > (int) DataSize-CurPos)
buffer_size = DataSize-CurPos;
int read = file_fd->read(buffer, buffer_size);
if(read > 0)
{
CurPos += read;
}
return read;
}

View File

@ -0,0 +1,50 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef AIFDECODER_HPP_
#define AIFDECODER_HPP_
#include "SoundDecoder.hpp"
#include "WavDecoder.hpp"
class AifDecoder : public SoundDecoder
{
public:
AifDecoder(const char * filepath);
AifDecoder(const u8 * snd, int len);
~AifDecoder();
int GetFormat() { return Format; };
int GetSampleRate() { return SampleRate; };
int Read(u8 * buffer, int buffer_size, int pos);
protected:
void OpenFile();
void CloseFile();
u32 DataOffset;
u32 DataSize;
u32 SampleRate;
u8 Format;
};
#endif

View File

@ -0,0 +1,363 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <malloc.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include "BNSDecoder.hpp"
BNSDecoder::BNSDecoder(const char * filepath)
: SoundDecoder(filepath)
{
SoundType = SOUND_BNS;
memset(&SoundData, 0, sizeof(SoundBlock));
if(!file_fd)
return;
OpenFile();
}
BNSDecoder::BNSDecoder(const u8 * snd, int len)
: SoundDecoder(snd, len)
{
SoundType = SOUND_BNS;
memset(&SoundData, 0, sizeof(SoundBlock));
if(!file_fd)
return;
OpenFile();
}
BNSDecoder::~BNSDecoder()
{
ExitRequested = true;
while(Decoding)
usleep(100);
if(SoundData.buffer != NULL)
free(SoundData.buffer);
SoundData.buffer = NULL;
}
void BNSDecoder::OpenFile()
{
u8 * tempbuff = new (std::nothrow) u8[file_fd->size()];
if(!tempbuff)
{
CloseFile();
return;
}
int done = 0;
while(done < file_fd->size())
{
int read = file_fd->read(tempbuff, file_fd->size());
if(read > 0)
done += read;
else
{
CloseFile();
return;
}
}
SoundData = DecodefromBNS(tempbuff, done);
if(SoundData.buffer == NULL)
{
CloseFile();
return;
}
delete [] tempbuff;
tempbuff = NULL;
Decode();
}
void BNSDecoder::CloseFile()
{
if(file_fd)
delete file_fd;
file_fd = NULL;
}
int BNSDecoder::Read(u8 * buffer, int buffer_size, int pos)
{
if(!SoundData.buffer)
return -1;
if(SoundData.loopFlag)
{
int factor = SoundData.format == VOICE_STEREO_16BIT ? 4 : 2;
if(CurPos >= (int) SoundData.loopEnd*factor)
CurPos = SoundData.loopStart*factor;
if(buffer_size > (int) SoundData.loopEnd*factor-CurPos)
buffer_size = SoundData.loopEnd*factor-CurPos;
}
else
{
if(CurPos >= (int) SoundData.size)
return 0;
if(buffer_size > (int) SoundData.size-CurPos)
buffer_size = SoundData.size-CurPos;
}
memcpy(buffer, SoundData.buffer+CurPos, buffer_size);
CurPos += buffer_size;
return buffer_size;
}
struct BNSHeader
{
u32 fccBNS;
u32 magic;
u32 size;
u16 unk1;
u16 unk2;
u32 infoOffset;
u32 infoSize;
u32 dataOffset;
u32 dataSize;
} __attribute__((packed));
struct BNSInfo
{
u32 fccINFO;
u32 size;
u8 codecNum;
u8 loopFlag;
u8 chanCount;
u8 zero;
u16 freq;
u8 pad1[2];
u32 loopStart;
u32 loopEnd;
u32 offsetToChanStarts;
u8 pad2[4];
u32 chan1StartOffset;
u32 chan2StartOffset;
u32 chan1Start;
u32 coeff1Offset;
u8 pad3[4];
u32 chan2Start;
u32 coeff2Offset;
u8 pad4[4];
s16 coefficients1[8][2];
u16 chan1Gain;
u16 chan1PredictiveScale;
s16 chan1PrevSamples[2];
u16 chan1LoopPredictiveScale;
s16 chan1LoopPrevSamples[2];
u16 chan1LoopPadding;
s16 coefficients2[8][2];
u16 chan2Gain;
u16 chan2PredictiveScale;
s16 chan2PrevSamples[2];
u16 chan2LoopPredictiveScale;
s16 chan2LoopPrevSamples[2];
u16 chan2LoopPadding;
} __attribute__((packed));
struct BNSData
{
u32 fccDATA;
u32 size;
u8 data;
} __attribute__((packed));
struct ADPCMByte
{
s8 sample1 : 4;
s8 sample2 : 4;
} __attribute__((packed));
struct BNSADPCMBlock
{
u8 pad : 1;
u8 coeffIndex : 3;
u8 lshift : 4;
ADPCMByte samples[7];
} __attribute__((packed));
struct BNSDecObj
{
s16 prevSamples[2];
s16 coeff[8][2];
};
static void loadBNSInfo(BNSInfo &bnsInfo, const u8 *buffer)
{
const u8 *ptr = buffer + 8;
bnsInfo = *(const BNSInfo *)buffer;
if (bnsInfo.offsetToChanStarts == 0x18 && bnsInfo.chan1StartOffset == 0x20 && bnsInfo.chan2StartOffset == 0x2C
&& bnsInfo.coeff1Offset == 0x38 && bnsInfo.coeff2Offset == 0x68)
return;
bnsInfo.chan1StartOffset = *(const u32 *)(ptr + bnsInfo.offsetToChanStarts);
bnsInfo.chan1Start = *(const u32 *)(ptr + bnsInfo.chan1StartOffset);
bnsInfo.coeff1Offset = *(const u32 *)(ptr + bnsInfo.chan1StartOffset + 4);
if ((u8 *)bnsInfo.coefficients1 != ptr + bnsInfo.coeff1Offset)
memcpy(bnsInfo.coefficients1, ptr + bnsInfo.coeff1Offset, (u8 *)bnsInfo.coefficients2 - (u8 *)&bnsInfo.coefficients1);
if (bnsInfo.chanCount == 2)
{
bnsInfo.chan2StartOffset = *(const u32 *)(ptr + bnsInfo.offsetToChanStarts + 4);
bnsInfo.chan2Start = *(const u32 *)(ptr + bnsInfo.chan2StartOffset);
bnsInfo.coeff2Offset = *(const u32 *)(ptr + bnsInfo.chan2StartOffset + 4);
if ((u8 *)bnsInfo.coefficients2 != ptr + bnsInfo.coeff2Offset)
memcpy(bnsInfo.coefficients2, ptr + bnsInfo.coeff2Offset, (u8 *)bnsInfo.coefficients2 - (u8 *)&bnsInfo.coefficients1);
}
}
static void decodeADPCMBlock(s16 *buffer, const BNSADPCMBlock &block, BNSDecObj &bnsDec)
{
int h1 = bnsDec.prevSamples[0];
int h2 = bnsDec.prevSamples[1];
int c1 = bnsDec.coeff[block.coeffIndex][0];
int c2 = bnsDec.coeff[block.coeffIndex][1];
for (int i = 0; i < 14; ++i)
{
int nibSample = ((i & 1) == 0) ? block.samples[i / 2].sample1 : block.samples[i / 2].sample2;
int sampleDeltaHP = (nibSample << block.lshift) << 11;
int predictedSampleHP = c1 * h1 + c2 * h2;
int sampleHP = predictedSampleHP + sampleDeltaHP;
buffer[i] = std::min(std::max(-32768, (sampleHP + 1024) >> 11), 32767);
h2 = h1;
h1 = buffer[i];
}
bnsDec.prevSamples[0] = h1;
bnsDec.prevSamples[1] = h2;
}
static u8 * decodeBNS(u32 &size, const BNSInfo &bnsInfo, const BNSData &bnsData)
{
static s16 smplBlock[14];
BNSDecObj decObj;
int numBlocks = (bnsData.size - 8) / 8;
int numSamples = numBlocks * 14;
const BNSADPCMBlock *inputBuf = (const BNSADPCMBlock *)&bnsData.data;
u8 * buffer = (u8 *) malloc(numSamples * sizeof (s16));
s16 *outputBuf;
if (!buffer)
return buffer;
memcpy(decObj.coeff, bnsInfo.coefficients1, sizeof decObj.coeff);
memcpy(decObj.prevSamples, bnsInfo.chan1PrevSamples, sizeof decObj.prevSamples);
outputBuf = (s16 *)buffer;
if (bnsInfo.chanCount == 1)
for (int i = 0; i < numBlocks; ++i)
{
decodeADPCMBlock(smplBlock, inputBuf[i], decObj);
memcpy(outputBuf, smplBlock, sizeof smplBlock);
outputBuf += 14;
}
else
{
numBlocks /= 2;
for (int i = 0; i < numBlocks; ++i)
{
decodeADPCMBlock(smplBlock, inputBuf[i], decObj);
for (int j = 0; j < 14; ++j)
outputBuf[j * 2] = smplBlock[j];
outputBuf += 2 * 14;
}
outputBuf = (s16 *)buffer + 1;
memcpy(decObj.coeff, bnsInfo.coefficients2, sizeof decObj.coeff);
memcpy(decObj.prevSamples, bnsInfo.chan2PrevSamples, sizeof decObj.prevSamples);
for (int i = 0; i < numBlocks; ++i)
{
decodeADPCMBlock(smplBlock, inputBuf[numBlocks + i], decObj);
for (int j = 0; j < 14; ++j)
outputBuf[j * 2] = smplBlock[j];
outputBuf += 2 * 14;
}
}
size = numSamples * sizeof (s16);
return buffer;
}
SoundBlock DecodefromBNS(const u8 *buffer, u32 size)
{
SoundBlock OutBlock;
memset(&OutBlock, 0, sizeof(SoundBlock));
const BNSHeader &hdr = *(BNSHeader *)buffer;
if (size < sizeof hdr)
return OutBlock;
if (hdr.fccBNS != 'BNS ')
return OutBlock;
// Find info and data
BNSInfo infoChunk;
loadBNSInfo(infoChunk, buffer + hdr.infoOffset);
const BNSData &dataChunk = *(const BNSData *)(buffer + hdr.dataOffset);
// Check sizes
if (size < hdr.size || size < hdr.infoOffset + hdr.infoSize || size < hdr.dataOffset + hdr.dataSize
|| hdr.infoSize < 0x60 || hdr.dataSize < sizeof dataChunk
|| infoChunk.size != hdr.infoSize || dataChunk.size != hdr.dataSize)
return OutBlock;
// Check format
if (infoChunk.codecNum != 0) // Only codec i've found : 0 = ADPCM. Maybe there's also 1 and 2 for PCM 8 or 16 bits ?
return OutBlock;
u8 format = (u8)-1;
if (infoChunk.chanCount == 1 && infoChunk.codecNum == 0)
format = VOICE_MONO_16BIT;
else if (infoChunk.chanCount == 2 && infoChunk.codecNum == 0)
format = VOICE_STEREO_16BIT;
if (format == (u8)-1)
return OutBlock;
u32 freq = (u32) infoChunk.freq;
u32 length = 0;
// Copy data
if (infoChunk.codecNum == 0)
{
OutBlock.buffer = decodeBNS(length, infoChunk, dataChunk);
if (!OutBlock.buffer)
return OutBlock;
}
else
{
OutBlock.buffer = (u8*) malloc(dataChunk.size);
if (!OutBlock.buffer)
return OutBlock;
memcpy(OutBlock.buffer, &dataChunk.data, dataChunk.size);
length = dataChunk.size;
}
OutBlock.frequency = freq;
OutBlock.format = format;
OutBlock.size = length;
OutBlock.loopStart = infoChunk.loopStart;
OutBlock.loopEnd = infoChunk.loopEnd;
OutBlock.loopFlag = infoChunk.loopFlag;
return OutBlock;
}

View File

@ -0,0 +1,59 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef BNSDECODER_HPP_
#define BNSDECODER_HPP_
#include "SoundDecoder.hpp"
typedef struct _SoundBlock
{
u8 * buffer;
u32 size;
u8 format;
u32 frequency;
u32 loopStart;
u32 loopEnd;
u8 loopFlag;
} SoundBlock;
class BNSDecoder : public SoundDecoder
{
public:
BNSDecoder(const char * filepath);
BNSDecoder(const u8 * snd, int len);
~BNSDecoder();
int GetFormat() { return SoundData.format; };
int GetSampleRate() { return SoundData.frequency; };
int Read(u8 * buffer, int buffer_size, int pos);
protected:
void OpenFile();
void CloseFile();
SoundBlock SoundData;
};
SoundBlock DecodefromBNS(const u8 *buffer, u32 size);
#endif

View File

@ -0,0 +1,144 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <malloc.h>
#include "BufferCircle.hpp"
#define ALIGN32(x) (((x) + 31) & ~31)
BufferCircle::BufferCircle()
{
which = 0;
BufferBlockSize = 0;
}
BufferCircle::~BufferCircle()
{
FreeBuffer();
SoundBuffer.clear();
BufferSize.clear();
BufferReady.clear();
}
void BufferCircle::SetBufferBlockSize(int size)
{
if(size < 0)
return;
BufferBlockSize = size;
for(int i = 0; i < Size(); i++)
{
if(SoundBuffer[i] != NULL)
free(SoundBuffer[i]);
SoundBuffer[i] = (u8 *) memalign(32, ALIGN32(BufferBlockSize));
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
void BufferCircle::Resize(int size)
{
while(size < Size())
RemoveBuffer(Size()-1);
int oldSize = Size();
SoundBuffer.resize(size);
BufferSize.resize(size);
BufferReady.resize(size);
for(int i = oldSize; i < Size(); i++)
{
if(BufferBlockSize > 0)
SoundBuffer[i] = (u8 *) memalign(32, ALIGN32(BufferBlockSize));
else
SoundBuffer[i] = NULL;
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
void BufferCircle::RemoveBuffer(int pos)
{
if(!Valid(pos))
return;
if(SoundBuffer[pos] != NULL)
free(SoundBuffer[pos]);
SoundBuffer.erase(SoundBuffer.begin()+pos);
BufferSize.erase(BufferSize.begin()+pos);
BufferReady.erase(BufferReady.begin()+pos);
}
void BufferCircle::ClearBuffer()
{
for(int i = 0; i < Size(); i++)
{
BufferSize[i] = 0;
BufferReady[i] = false;
}
which = 0;
}
void BufferCircle::FreeBuffer()
{
for(int i = 0; i < Size(); i++)
{
if(SoundBuffer[i] != NULL)
free(SoundBuffer[i]);
SoundBuffer[i] = NULL;
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
void BufferCircle::LoadNext()
{
int pos = (which+Size()-1) % Size();
BufferReady[pos] = false;
BufferSize[pos] = 0;
which = (which+1) % Size();
}
void BufferCircle::SetBufferReady(int pos, bool state)
{
if(!Valid(pos))
return;
BufferReady[pos] = state;
}
void BufferCircle::SetBufferSize(int pos, int size)
{
if(!Valid(pos))
return;
BufferSize[pos] = size;
}

View File

@ -0,0 +1,92 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef BUFFER_CIRCLE_HPP_
#define BUFFER_CIRCLE_HPP_
#include <vector>
#include <gctypes.h>
class BufferCircle
{
public:
//!> Constructor
BufferCircle();
//!> Destructor
~BufferCircle();
//!> Set circle size
void Resize(int size);
//!> Get the circle size
int Size() { return SoundBuffer.size(); };
//!> Set/resize the buffer size
void SetBufferBlockSize(int size);
//!> Remove a buffer
void RemoveBuffer(int pos);
//!> Set all buffers clear
void ClearBuffer();
//!> Free all buffers
void FreeBuffer();
//!> Switch to next buffer
void LoadNext();
//!> Get the current buffer
u8 * GetBuffer() { if(!Valid(which)) return 0; return SoundBuffer[which]; };
//!> Get a buffer at a position
u8 * GetBuffer(int pos) { if(!Valid(pos)) return NULL; else return SoundBuffer[pos]; };
//!> Get next buffer
u8 * GetNextBuffer() { if(Size() <= 0) return 0; else return SoundBuffer[(which+1) % Size()]; };
//!> Get previous buffer
u8 * GetLastBuffer() { if(Size() <= 0) return 0; else return SoundBuffer[(which+Size()-1) % Size()]; };
//!> Get current buffer size
u32 GetBufferSize() { if(!Valid(which)) return 0; else return BufferSize[which]; };
//!> Get buffer size at position
u32 GetBufferSize(int pos) { if(!Valid(pos)) return 0; else return BufferSize[pos]; };
//!> Get previous buffer size
u32 GetLastBufferSize() { if(Size() <= 0) return 0; else return BufferSize[(which+Size()-1) % Size()]; };
//!> Is current buffer ready
bool IsBufferReady() { if(!Valid(which)) return false; else return BufferReady[which]; };
//!> Is a buffer at a position ready
bool IsBufferReady(int pos) { if(!Valid(pos)) return false; else return BufferReady[pos]; };
//!> Is next buffer ready
bool IsNextBufferReady() { if(Size() <= 0) return false; else return BufferReady[(which+1) % Size()]; };
//!> Is last buffer ready
bool IsLastBufferReady() { if(Size() <= 0) return false; else return BufferReady[(which+Size()-1) % Size()]; };
//!> Set a buffer at a position to a ready state
void SetBufferReady(int pos, bool st);
//!> Set the buffersize at a position
void SetBufferSize(int pos, int size);
//!> Get the current position in the circle
u16 Which() { return which; };
protected:
//!> Check if the position is a valid position in the vector
bool Valid(int pos) { return !(which < 0 || which >= Size()); };
u16 which;
u32 BufferBlockSize;
std::vector<u8 *> SoundBuffer;
std::vector<u32> BufferSize;
std::vector<bool> BufferReady;
};
#endif

View File

@ -0,0 +1,216 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <string>
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <malloc.h>
#include <math.h>
#include "Mp3Decoder.hpp"
Mp3Decoder::Mp3Decoder(const char * filepath)
: SoundDecoder(filepath)
{
SoundType = SOUND_MP3;
ReadBuffer = NULL;
mad_timer_reset(&Timer);
mad_stream_init(&Stream);
mad_frame_init(&Frame);
mad_synth_init(&Synth);
if(!file_fd)
return;
OpenFile();
}
Mp3Decoder::Mp3Decoder(const u8 * snd, int len)
: SoundDecoder(snd, len)
{
SoundType = SOUND_MP3;
ReadBuffer = NULL;
mad_timer_reset(&Timer);
mad_stream_init(&Stream);
mad_frame_init(&Frame);
mad_synth_init(&Synth);
if(!file_fd)
return;
OpenFile();
}
Mp3Decoder::~Mp3Decoder()
{
ExitRequested = true;
while(Decoding)
usleep(100);
mad_synth_finish(&Synth);
mad_frame_finish(&Frame);
mad_stream_finish(&Stream);
if(ReadBuffer)
free(ReadBuffer);
ReadBuffer = NULL;
}
void Mp3Decoder::OpenFile()
{
GuardPtr = NULL;
ReadBuffer = (u8 *) memalign(32, SoundBlockSize*SoundBlocks);
if(!ReadBuffer)
{
if(file_fd)
delete file_fd;
file_fd = NULL;
return;
}
u8 dummybuff[4096];
int ret = Read((u8 *) &dummybuff, 4096, 0);
if(ret <= 0)
{
if(file_fd)
delete file_fd;
file_fd = NULL;
return;
}
SampleRate = (u32) Frame.header.samplerate;
Format = ((MAD_NCHANNELS(&Frame.header) == 2) ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT);
Rewind();
Decode();
}
int Mp3Decoder::Rewind()
{
mad_synth_finish(&Synth);
mad_frame_finish(&Frame);
mad_stream_finish(&Stream);
mad_timer_reset(&Timer);
mad_stream_init(&Stream);
mad_frame_init(&Frame);
mad_synth_init(&Synth);
SynthPos = 0;
GuardPtr = NULL;
if(!file_fd)
return -1;
return SoundDecoder::Rewind();
}
static inline s16 FixedToShort(mad_fixed_t Fixed)
{
/* Clipping */
if(Fixed>=MAD_F_ONE)
return(SHRT_MAX);
if(Fixed<=-MAD_F_ONE)
return(-SHRT_MAX);
Fixed=Fixed>>(MAD_F_FRACBITS-15);
return((s16)Fixed);
}
int Mp3Decoder::Read(u8 * buffer, int buffer_size, int pos)
{
if(!file_fd)
return -1;
if(Format == VOICE_STEREO_16BIT)
buffer_size &= ~0x0003;
else
buffer_size &= ~0x0001;
u8 * write_pos = buffer;
u8 * write_end = buffer+buffer_size;
while(1)
{
while(SynthPos < Synth.pcm.length)
{
if(write_pos >= write_end)
return write_pos-buffer;
*((s16 *) write_pos) = FixedToShort(Synth.pcm.samples[0][SynthPos]);
write_pos += 2;
if(MAD_NCHANNELS(&Frame.header) == 2)
{
*((s16 *) write_pos) = FixedToShort(Synth.pcm.samples[1][SynthPos]);
write_pos += 2;
}
SynthPos++;
}
if(Stream.buffer == NULL || Stream.error == MAD_ERROR_BUFLEN)
{
u8 * ReadStart = ReadBuffer;
int ReadSize = SoundBlockSize*SoundBlocks;
int Remaining = 0;
if(Stream.next_frame != NULL)
{
Remaining = Stream.bufend - Stream.next_frame;
memmove(ReadBuffer, Stream.next_frame, Remaining);
ReadStart += Remaining;
ReadSize -= Remaining;
}
ReadSize = file_fd->read(ReadStart, ReadSize);
if(ReadSize <= 0)
{
GuardPtr = ReadStart;
memset(GuardPtr, 0, MAD_BUFFER_GUARD);
ReadSize = MAD_BUFFER_GUARD;
}
CurPos += ReadSize;
mad_stream_buffer(&Stream, ReadBuffer, Remaining+ReadSize);
}
if(mad_frame_decode(&Frame,&Stream))
{
if(MAD_RECOVERABLE(Stream.error))
{
if(Stream.error != MAD_ERROR_LOSTSYNC || !GuardPtr)
continue;
}
else
{
if(Stream.error != MAD_ERROR_BUFLEN)
return -1;
else if(Stream.error == MAD_ERROR_BUFLEN && GuardPtr)
return -1;
}
}
mad_timer_add(&Timer,Frame.header.duration);
mad_synth_frame(&Synth,&Frame);
SynthPos = 0;
}
}

View File

@ -0,0 +1,51 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <mad.h>
#include "SoundDecoder.hpp"
class Mp3Decoder : public SoundDecoder
{
public:
Mp3Decoder(const char * filepath);
Mp3Decoder(const u8 * sound, int len);
~Mp3Decoder();
int GetFormat() { return Format; };
int GetSampleRate() { return SampleRate; };
int Rewind();
int Read(u8 * buffer, int buffer_size, int pos);
protected:
void OpenFile();
struct mad_stream Stream;
struct mad_frame Frame;
struct mad_synth Synth;
mad_timer_t Timer;
u8 * GuardPtr;
u8 * ReadBuffer;
u8 Format;
u32 SampleRate;
u32 SynthPos;
};

View File

@ -0,0 +1,144 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <unistd.h>
#include <malloc.h>
#include "OggDecoder.hpp"
extern "C" int ogg_read(void * punt, int bytes, int blocks, int *f)
{
return ((CFile *) f)->read((u8 *) punt, bytes*blocks);
}
extern "C" int ogg_seek(int *f, ogg_int64_t offset, int mode)
{
return ((CFile *) f)->seek((u64) offset, mode);
}
extern "C" int ogg_close(int *f)
{
((CFile *) f)->close();
return 0;
}
extern "C" long ogg_tell(int *f)
{
return (long) ((CFile *) f)->tell();
}
static ov_callbacks callbacks = {
(size_t (*)(void *, size_t, size_t, void *)) ogg_read,
(int (*)(void *, ogg_int64_t, int)) ogg_seek,
(int (*)(void *)) ogg_close,
(long (*)(void *)) ogg_tell
};
OggDecoder::OggDecoder(const char * filepath)
: SoundDecoder(filepath)
{
SoundType = SOUND_OGG;
if(!file_fd)
return;
OpenFile();
}
OggDecoder::OggDecoder(const u8 * snd, int len)
: SoundDecoder(snd, len)
{
SoundType = SOUND_OGG;
if(!file_fd)
return;
OpenFile();
}
OggDecoder::~OggDecoder()
{
ExitRequested = true;
while(Decoding)
usleep(100);
if(file_fd)
ov_clear(&ogg_file);
}
void OggDecoder::OpenFile()
{
if (ov_open_callbacks(file_fd, &ogg_file, NULL, 0, callbacks) < 0)
{
delete file_fd;
file_fd = NULL;
return;
}
ogg_info = ov_info(&ogg_file, -1);
Decode();
}
int OggDecoder::GetFormat()
{
if(!file_fd)
return VOICE_STEREO_16BIT;
return ((ogg_info->channels == 2) ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT);
}
int OggDecoder::GetSampleRate()
{
if(!file_fd)
return 0;
return (int) ogg_info->rate;
}
int OggDecoder::Rewind()
{
if(!file_fd)
return -1;
int ret = ov_time_seek(&ogg_file, 0);
CurPos = 0;
EndOfFile = false;
return ret;
}
int OggDecoder::Read(u8 * buffer, int buffer_size, int pos)
{
if(!file_fd)
return -1;
int bitstream = 0;
int read = ov_read(&ogg_file, (char *) buffer, buffer_size, &bitstream);
if(read > 0)
CurPos += read;
return read;
}

View File

@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <tremor/ivorbiscodec.h>
#include <tremor/ivorbisfile.h>
#include "SoundDecoder.hpp"
class OggDecoder : public SoundDecoder
{
public:
OggDecoder(const char * filepath);
OggDecoder(const u8 * snd, int len);
~OggDecoder();
int GetFormat();
int GetSampleRate();
int Rewind();
int Read(u8 * buffer, int buffer_size, int pos);
protected:
void OpenFile();
OggVorbis_File ogg_file;
vorbis_info *ogg_info;
};

View File

@ -0,0 +1,156 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* 3Band resampling thanks to libmad
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <gccore.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include "SoundDecoder.hpp"
#include "main.h"
SoundDecoder::SoundDecoder()
{
file_fd = NULL;
Init();
}
SoundDecoder::SoundDecoder(const char * filepath)
{
file_fd = new CFile(filepath, "rb");
Init();
}
SoundDecoder::SoundDecoder(const u8 * buffer, int size)
{
file_fd = new CFile(buffer, size);
Init();
}
SoundDecoder::~SoundDecoder()
{
ExitRequested = true;
while(Decoding)
usleep(100);
if(file_fd)
delete file_fd;
file_fd = NULL;
}
void SoundDecoder::Init()
{
SoundType = SOUND_RAW;
SoundBlocks = 8;
SoundBlockSize = 8192;
CurPos = 0;
Loop = false;
EndOfFile = false;
Decoding = false;
ExitRequested = false;
SoundBuffer.SetBufferBlockSize(SoundBlockSize);
SoundBuffer.Resize(SoundBlocks);
}
int SoundDecoder::Rewind()
{
CurPos = 0;
EndOfFile = false;
file_fd->rewind();
return 0;
}
int SoundDecoder::Read(u8 * buffer, int buffer_size, int pos)
{
int ret = file_fd->read(buffer, buffer_size);
CurPos += ret;
return ret;
}
void SoundDecoder::Decode()
{
if(!file_fd || ExitRequested || EndOfFile)
return;
u16 newWhich = SoundBuffer.Which();
u16 i = 0;
for (i = 0; i < SoundBuffer.Size()-2; i++)
{
if(!SoundBuffer.IsBufferReady(newWhich))
break;
newWhich = (newWhich+1) % SoundBuffer.Size();
}
if(i == SoundBuffer.Size()-2)
return;
Decoding = true;
int done = 0;
u8 * write_buf = SoundBuffer.GetBuffer(newWhich);
if(!write_buf)
{
ExitRequested = true;
Decoding = false;
return;
}
while(done < SoundBlockSize)
{
int ret = Read(&write_buf[done], SoundBlockSize-done, Tell());
if(ret <= 0)
{
if(Loop)
{
Rewind();
continue;
}
else
{
EndOfFile = true;
break;
}
}
done += ret;
}
if(done > 0)
{
SoundBuffer.SetBufferSize(newWhich, done);
SoundBuffer.SetBufferReady(newWhich, true);
}
if(!SoundBuffer.IsBufferReady((newWhich+1) % SoundBuffer.Size()))
Decode();
Decoding = false;
}

View File

@ -0,0 +1,89 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef SOUND_DECODER_HPP
#define SOUND_DECODER_HPP
#include <stdio.h>
#include <gctypes.h>
#include <asndlib.h>
#include "utils/timer.h"
#include "FileOperations/File.hpp"
#include "BufferCircle.hpp"
enum
{
SOUND_RAW = 0,
SOUND_MP3,
SOUND_OGG,
SOUND_WAV,
SOUND_BNS,
SOUND_AIF
};
class SoundDecoder
{
public:
SoundDecoder();
SoundDecoder(const char * filepath);
SoundDecoder(const u8 * buffer, int size);
~SoundDecoder();
virtual int Read(u8 * buffer, int buffer_size, int pos);
virtual int Tell() { return CurPos; };
virtual int Seek(int pos) { CurPos = pos; return file_fd->seek(CurPos, SEEK_SET); };
virtual int Rewind();
virtual int GetFormat() { return VOICE_STEREO_16BIT; };
virtual int GetSampleRate() { return 48000; };
virtual void Decode();
virtual u32 GetBufferSize() { return SoundBuffer.GetBufferSize(); };
virtual u8 * GetBuffer() { return SoundBuffer.GetBuffer(); };
virtual u8 * GetNextBuffer() { return SoundBuffer.GetNextBuffer(); };
virtual u8 * GetLastBuffer() { return SoundBuffer.GetLastBuffer(); };
virtual void LoadNext() { SoundBuffer.LoadNext(); };
virtual bool IsBufferReady() { return SoundBuffer.IsBufferReady(); };
virtual bool IsNextBufferReady() { return SoundBuffer.IsNextBufferReady(); };
virtual bool IsLastBufferReady() { return SoundBuffer.IsLastBufferReady(); };
virtual bool IsEOF() { return EndOfFile; };
virtual void SetLoop(bool l) { Loop = l; };
virtual u8 GetSoundType() { return SoundType; };
virtual void ClearBuffer() { SoundBuffer.ClearBuffer(); };
virtual bool IsStereo() { return (GetFormat() == VOICE_STEREO_16BIT || GetFormat() == VOICE_STEREO_8BIT); };
virtual bool Is16Bit() { return (GetFormat() == VOICE_STEREO_16BIT || GetFormat() == VOICE_MONO_16BIT); };
protected:
void Init();
CFile * file_fd;
BufferCircle SoundBuffer;
u8 SoundType;
u16 SoundBlocks;
int SoundBlockSize;
int CurPos;
bool Loop;
bool EndOfFile;
bool Decoding;
bool ExitRequested;
};
#endif

View File

@ -0,0 +1,271 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <unistd.h>
#include <malloc.h>
#include "SoundHandler.hpp"
#include "Mp3Decoder.hpp"
#include "OggDecoder.hpp"
#include "WavDecoder.hpp"
#include "AifDecoder.hpp"
#include "BNSDecoder.hpp"
SoundHandler * SoundHandler::instance = NULL;
SoundHandler::SoundHandler()
{
Decoding = false;
ExitRequested = false;
for(u32 i = 0; i < MAX_DECODERS; ++i)
DecoderList[i] = NULL;
ThreadStack = (u8 *) memalign(32, 32768);
if(!ThreadStack)
return;
LWP_CreateThread(&SoundThread, UpdateThread, this, ThreadStack, 32768, 80);
}
SoundHandler::~SoundHandler()
{
ExitRequested = true;
ThreadSignal();
LWP_JoinThread(SoundThread, NULL);
SoundThread = LWP_THREAD_NULL;
if(ThreadStack)
free(ThreadStack);
ClearDecoderList();
}
SoundHandler * SoundHandler::Instance()
{
if (instance == NULL)
{
instance = new SoundHandler();
}
return instance;
}
void SoundHandler::DestroyInstance()
{
if(instance)
{
delete instance;
}
instance = NULL;
}
void SoundHandler::AddDecoder(int voice, const char * filepath)
{
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(DecoderList[voice] != NULL)
RemoveDecoder(voice);
DecoderList[voice] = GetSoundDecoder(filepath);
}
void SoundHandler::AddDecoder(int voice, const u8 * snd, int len)
{
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(DecoderList[voice] != NULL)
RemoveDecoder(voice);
DecoderList[voice] = GetSoundDecoder(snd, len);
}
void SoundHandler::RemoveDecoder(int voice)
{
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(DecoderList[voice] != NULL)
{
if(DecoderList[voice]->GetSoundType() == SOUND_OGG) delete ((OggDecoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_MP3) delete ((Mp3Decoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_WAV) delete ((WavDecoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_AIF) delete ((AifDecoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_BNS) delete ((BNSDecoder *) DecoderList[voice]);
else delete DecoderList[voice];
}
DecoderList[voice] = NULL;
}
void SoundHandler::ClearDecoderList()
{
for(u32 i = 0; i < MAX_DECODERS; ++i)
RemoveDecoder(i);
}
static inline bool CheckMP3Signature(const u8 * buffer)
{
const char MP3_Magic[][3] =
{
{'I', 'D', '3'}, //'ID3'
{0xff, 0xfe}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xff}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xfa}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xfb}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf2}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf3}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf4}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf5}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf6}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf7}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xe2}, //'MPEG ADTS, layer III, v2.5 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xe3}, //'MPEG ADTS, layer III, v2.5', 'mp3', 'audio/mpeg'),
};
if(buffer[0] == MP3_Magic[0][0] && buffer[1] == MP3_Magic[0][1] &&
buffer[2] == MP3_Magic[0][2])
{
return true;
}
for(int i = 1; i < 13; i++)
{
if(buffer[0] == MP3_Magic[i][0] && buffer[1] == MP3_Magic[i][1])
return true;
}
return false;
}
SoundDecoder * SoundHandler::GetSoundDecoder(const char * filepath)
{
u32 magic;
CFile f(filepath, "rb");
if(f.size() == 0)
return NULL;
do
{
f.read((u8 *) &magic, 1);
}
while(((u8 *) &magic)[0] == 0 && f.tell() < f.size());
if(f.tell() == f.size())
return NULL;
f.seek(f.tell()-1, SEEK_SET);
f.read((u8 *) &magic, 4);
f.close();
if(magic == 'OggS')
{
return new OggDecoder(filepath);
}
else if(magic == 'RIFF')
{
return new WavDecoder(filepath);
}
else if(magic == 'BNS ')
{
return new BNSDecoder(filepath);
}
else if(magic == 'FORM')
{
return new AifDecoder(filepath);
}
else if(CheckMP3Signature((u8 *) &magic) == true)
{
return new Mp3Decoder(filepath);
}
return new SoundDecoder(filepath);
}
SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length)
{
const u8 * check = sound;
int counter = 0;
while(check[0] == 0 && counter < length)
{
check++;
counter++;
}
if(counter >= length)
return NULL;
u32 * magic = (u32 *) check;
if(magic[0] == 'OggS')
{
return new OggDecoder(sound, length);
}
else if(magic[0] == 'RIFF')
{
return new WavDecoder(sound, length);
}
else if(magic[0] == 'BNS ')
{
return new BNSDecoder(sound, length);
}
else if(magic[0] == 'FORM')
{
return new AifDecoder(sound, length);
}
else if(CheckMP3Signature(check) == true)
{
return new Mp3Decoder(sound, length);
}
return new SoundDecoder(sound, length);
}
void * SoundHandler::UpdateThread(void *arg)
{
((SoundHandler *) arg)->InternalSoundUpdates();
return NULL;
}
void SoundHandler::InternalSoundUpdates()
{
u16 i = 0;
LWP_InitQueue(&ThreadQueue);
while (!ExitRequested)
{
LWP_ThreadSleep(ThreadQueue);
for(i = 0; i < MAX_DECODERS; ++i)
{
if(DecoderList[i] == NULL)
continue;
Decoding = true;
DecoderList[i]->Decode();
}
Decoding = false;
}
LWP_CloseQueue(ThreadQueue);
ThreadQueue = LWP_TQUEUE_NULL;
}

View File

@ -0,0 +1,68 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef SOUNDHANDLER_H_
#define SOUNDHANDLER_H_
#include <vector>
#include <gccore.h>
#include "SoundDecoder.hpp"
#define MAX_DECODERS 16
class SoundHandler
{
public:
static SoundHandler * Instance();
static void DestroyInstance();
void AddDecoder(int voice, const char * filepath);
void AddDecoder(int voice, const u8 * snd, int len);
void RemoveDecoder(int voice);
void DestroyDecoder(SoundDecoder * decoder);
SoundDecoder * Decoder(int i) { return ((i < 0 || i >= MAX_DECODERS) ? NULL : DecoderList[i]); };
void ThreadSignal() { LWP_ThreadSignal(ThreadQueue); };
bool IsDecoding() { return Decoding; };
protected:
SoundHandler();
~SoundHandler();
static void * UpdateThread(void *arg);
void InternalSoundUpdates();
void ClearDecoderList();
SoundDecoder * GetSoundDecoder(const char * filepath);
SoundDecoder * GetSoundDecoder(const u8 * sound, int length);
static SoundHandler * instance;
u8 * ThreadStack;
lwp_t SoundThread;
lwpq_t ThreadQueue;
bool Decoding;
bool ExitRequested;
SoundDecoder * DecoderList[MAX_DECODERS];
};
#endif

View File

@ -0,0 +1,155 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <string.h>
#include "WavDecoder.hpp"
#include "utils/uncompress.h"
WavDecoder::WavDecoder(const char * filepath)
: SoundDecoder(filepath)
{
SoundType = SOUND_WAV;
SampleRate = 48000;
Format = VOICE_STEREO_16BIT;
if(!file_fd)
return;
OpenFile();
}
WavDecoder::WavDecoder(const u8 * snd, int len)
: SoundDecoder(snd, len)
{
SoundType = SOUND_WAV;
SampleRate = 48000;
Format = VOICE_STEREO_16BIT;
if(!file_fd)
return;
OpenFile();
}
WavDecoder::~WavDecoder()
{
}
void WavDecoder::OpenFile()
{
SWaveHdr Header;
SWaveFmtChunk FmtChunk;
memset(&Header, 0, sizeof(SWaveHdr));
memset(&FmtChunk, 0, sizeof(SWaveFmtChunk));
file_fd->read((u8 *) &Header, sizeof(SWaveHdr));
file_fd->read((u8 *) &FmtChunk, sizeof(SWaveFmtChunk));
if (Header.magicRIFF != 'RIFF')
{
CloseFile();
return;
}
else if(Header.magicWAVE != 'WAVE')
{
CloseFile();
return;
}
else if(FmtChunk.magicFMT != 'fmt ')
{
CloseFile();
return;
}
DataOffset = sizeof(SWaveHdr)+le32(FmtChunk.size)+8;
file_fd->seek(DataOffset, SEEK_SET);
SWaveChunk DataChunk;
file_fd->read((u8 *) &DataChunk, sizeof(SWaveChunk));
if(DataChunk.magicDATA == 'fact')
{
DataOffset += 8+le32(DataChunk.size);
file_fd->seek(DataOffset, SEEK_SET);
file_fd->read((u8 *) &DataChunk, sizeof(SWaveChunk));
}
if(DataChunk.magicDATA != 'data')
{
CloseFile();
return;
}
DataOffset += 8;
DataSize = le32(DataChunk.size);
Is16Bit = (le16(FmtChunk.bps) == 16);
SampleRate = le32(FmtChunk.freq);
if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 1)
Format = VOICE_MONO_8BIT;
else if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 2)
Format = VOICE_MONO_16BIT;
else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 2)
Format = VOICE_STEREO_8BIT;
else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 4)
Format = VOICE_STEREO_16BIT;
Decode();
}
void WavDecoder::CloseFile()
{
if(file_fd)
delete file_fd;
file_fd = NULL;
}
int WavDecoder::Read(u8 * buffer, int buffer_size, int pos)
{
if(!file_fd)
return -1;
if(CurPos >= (int) DataSize)
return 0;
file_fd->seek(DataOffset+CurPos, SEEK_SET);
if(buffer_size > (int) DataSize-CurPos)
buffer_size = DataSize-CurPos;
int read = file_fd->read(buffer, buffer_size);
if(read > 0)
{
if (Is16Bit)
{
read &= ~0x0001;
for (u32 i = 0; i < (u32) (read / sizeof (u16)); ++i)
((u16 *) buffer)[i] = le16(((u16 *) buffer)[i]);
}
CurPos += read;
}
return read;
}

View File

@ -0,0 +1,75 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef WAVDECODER_HPP_
#define WAVDECODER_HPP_
#include "SoundDecoder.hpp"
typedef struct
{
u32 magicRIFF;
u32 size;
u32 magicWAVE;
} SWaveHdr;
typedef struct
{
u32 magicFMT;
u32 size;
u16 format;
u16 channels;
u32 freq;
u32 avgBps;
u16 alignment;
u16 bps;
} SWaveFmtChunk;
typedef struct
{
u32 magicDATA;
u32 size;
} SWaveChunk;
class WavDecoder : public SoundDecoder
{
public:
WavDecoder(const char * filepath);
WavDecoder(const u8 * snd, int len);
~WavDecoder();
int GetFormat() { return Format; };
int GetSampleRate() { return SampleRate; };
int Read(u8 * buffer, int buffer_size, int pos);
protected:
void OpenFile();
void CloseFile();
u32 DataOffset;
u32 DataSize;
u32 SampleRate;
u8 Format;
bool Is16Bit;
};
#endif

View File

@ -1,236 +1,224 @@
/****************************************************************************
* SettingsPrompts
* USB Loader GX 2009
*
* Backgroundmusic
***************************************************************************/
#include <sys/dir.h>
#include "gui_bgm.h"
#include "menu.h"
GuiBGM::GuiBGM(const u8 *s, int l, int v) :
GuiSound(s, l, v)
{
loop = 0;
loopMode = ONCE;
currentPath = NULL;
currentPlaying = 0;
//shouldn't be needed but
//fixes some kind of weird bug in ogg system
GuiSound::Load(s, l, v);
}
GuiBGM::~GuiBGM()
{
if (currentPath) delete[] currentPath;
ClearList();
}
;
void GuiBGM::SetLoop(bool l)
{
}
void GuiBGM::SetLoop(int l)
{
loop = false;
loopMode = ONCE;
if (l == LOOP)
{
loop = true;
}
else loopMode = l;
}
bool GuiBGM::Load(const char *path)
{
if (!path)
{
LoadStandard();
return false;
}
if (strcmp(path, "") == 0)
{
LoadStandard();
return false;
}
if (!GuiSound::Load(path))
{
LoadStandard();
return false;
}
return ParsePath(path);
}
bool GuiBGM::LoadStandard()
{
ClearList();
if (currentPath)
{
delete[] currentPath;
currentPath = NULL;
}
strcpy(Settings.ogg_path, "");
bool ret = GuiSound::Load(bg_music_ogg, bg_music_ogg_size, true);
if (ret) Play();
return ret;
}
bool GuiBGM::ParsePath(const char * folderpath)
{
ClearList();
if (currentPath) delete[] currentPath;
currentPath = new char[strlen(folderpath) + 1];
sprintf(currentPath, "%s", folderpath);
char * isdirpath = strrchr(folderpath, '.');
if (isdirpath)
{
char * pathptr = strrchr(currentPath, '/');
if (pathptr)
{
pathptr++;
pathptr[0] = 0;
}
}
char * LoadedFilename = strrchr(folderpath, '/') + 1;
char filename[1024];
struct stat st;
DIR_ITER * dir = diropen(currentPath);
if (dir == NULL)
{
LoadStandard();
return false;
}
u32 counter = 0;
while (dirnext(dir, filename, &st) == 0)
{
char * fileext = strrchr(filename, '.');
if (fileext)
{
if (strcasecmp(fileext, ".mp3") == 0 || strcasecmp(fileext, ".ogg") == 0 || strcasecmp(fileext, ".wav")
== 0)
{
AddEntrie(filename);
if (strcmp(LoadedFilename, filename) == 0) currentPlaying = counter;
counter++;
}
}
}
dirclose(dir);
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s", folderpath);
return true;
}
void GuiBGM::AddEntrie(const char * filename)
{
if (!filename) return;
char * NewEntrie = new char[strlen(filename) + 1];
sprintf(NewEntrie, "%s", filename);
PlayList.push_back(NewEntrie);
}
void GuiBGM::ClearList()
{
for (u32 i = 0; i < PlayList.size(); i++)
{
if (PlayList.at(i) != NULL)
{
delete[] PlayList.at(i);
PlayList.at(i) = NULL;
}
}
PlayList.clear();
}
bool GuiBGM::PlayNext()
{
if (!currentPath) return false;
currentPlaying++;
if (currentPlaying >= (int) PlayList.size()) currentPlaying = 0;
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s%s", currentPath, PlayList.at(currentPlaying));
if (!GuiSound::Load(Settings.ogg_path)) return false;
Play();
return true;
}
bool GuiBGM::PlayPrevious()
{
if (!currentPath) return false;
currentPlaying--;
if (currentPlaying < 0) currentPlaying = PlayList.size() - 1;
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s%s", currentPath, PlayList.at(currentPlaying));
if (!GuiSound::Load(Settings.ogg_path)) return false;
Play();
return true;
}
bool GuiBGM::PlayRandom()
{
if (!currentPath) return false;
srand(time(NULL));
currentPlaying = rand() % PlayList.size();
//just in case
if (currentPlaying < 0)
currentPlaying = PlayList.size() - 1;
else if (currentPlaying >= (int) PlayList.size()) currentPlaying = 0;
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s%s", currentPath, PlayList.at(currentPlaying));
if (!GuiSound::Load(Settings.ogg_path)) return false;
Play();
return true;
}
void GuiBGM::UpdateState()
{
if (!IsPlaying())
{
if (loopMode == DIR_LOOP)
{
PlayNext();
}
else if (loopMode == RANDOM_BGM)
{
PlayRandom();
}
}
}
/****************************************************************************
* SettingsPrompts
* USB Loader GX 2009
*
* Backgroundmusic
***************************************************************************/
#include <sys/dir.h>
#include "gui_bgm.h"
#include "menu.h"
GuiBGM::GuiBGM(const u8 *s, int l, int v) :
GuiSound(s, l, v, false, 0)
{
loop = 0;
loopMode = ONCE;
currentPath = NULL;
currentPlaying = 0;
voice = 0;
}
GuiBGM::~GuiBGM()
{
if (currentPath) delete[] currentPath;
ClearList();
}
;
void GuiBGM::SetLoop(u8 l)
{
loopMode = l;
GuiSound::SetLoop(l == LOOP);
}
bool GuiBGM::Load(const char *path)
{
if (!path)
{
LoadStandard();
return false;
}
if (strcmp(path, "") == 0)
{
LoadStandard();
return false;
}
if (!GuiSound::Load(path))
{
LoadStandard();
return false;
}
return ParsePath(path);
}
bool GuiBGM::LoadStandard()
{
ClearList();
if (currentPath)
{
delete[] currentPath;
currentPath = NULL;
}
strcpy(Settings.ogg_path, "");
bool ret = GuiSound::Load(bg_music_ogg, bg_music_ogg_size, false);
if (ret) Play();
return ret;
}
bool GuiBGM::ParsePath(const char * folderpath)
{
ClearList();
if (currentPath) delete[] currentPath;
currentPath = new char[strlen(folderpath) + 1];
sprintf(currentPath, "%s", folderpath);
char * isdirpath = strrchr(folderpath, '.');
if (isdirpath)
{
char * pathptr = strrchr(currentPath, '/');
if (pathptr)
{
pathptr++;
pathptr[0] = 0;
}
}
char * LoadedFilename = strrchr(folderpath, '/') + 1;
char filename[1024];
struct stat st;
DIR_ITER * dir = diropen(currentPath);
if (dir == NULL)
{
LoadStandard();
return false;
}
u32 counter = 0;
while (dirnext(dir, filename, &st) == 0)
{
char * fileext = strrchr(filename, '.');
if (fileext)
{
if (strcasecmp(fileext, ".mp3") == 0 || strcasecmp(fileext, ".ogg") == 0 || strcasecmp(fileext, ".wav")
== 0)
{
AddEntrie(filename);
if (strcmp(LoadedFilename, filename) == 0) currentPlaying = counter;
counter++;
}
}
}
dirclose(dir);
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s", folderpath);
return true;
}
void GuiBGM::AddEntrie(const char * filename)
{
if (!filename) return;
char * NewEntrie = new char[strlen(filename) + 1];
sprintf(NewEntrie, "%s", filename);
PlayList.push_back(NewEntrie);
}
void GuiBGM::ClearList()
{
for (u32 i = 0; i < PlayList.size(); i++)
{
if (PlayList.at(i) != NULL)
{
delete[] PlayList.at(i);
PlayList.at(i) = NULL;
}
}
PlayList.clear();
}
bool GuiBGM::PlayNext()
{
if (!currentPath) return false;
currentPlaying++;
if (currentPlaying >= (int) PlayList.size()) currentPlaying = 0;
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s%s", currentPath, PlayList.at(currentPlaying));
if (!GuiSound::Load(Settings.ogg_path)) return false;
Play();
return true;
}
bool GuiBGM::PlayPrevious()
{
if (!currentPath) return false;
currentPlaying--;
if (currentPlaying < 0) currentPlaying = PlayList.size() - 1;
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s%s", currentPath, PlayList.at(currentPlaying));
if (!GuiSound::Load(Settings.ogg_path)) return false;
Play();
return true;
}
bool GuiBGM::PlayRandom()
{
if (!currentPath) return false;
srand(time(NULL));
currentPlaying = rand() % PlayList.size();
//just in case
if (currentPlaying < 0)
currentPlaying = PlayList.size() - 1;
else if (currentPlaying >= (int) PlayList.size()) currentPlaying = 0;
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s%s", currentPath, PlayList.at(currentPlaying));
if (!GuiSound::Load(Settings.ogg_path)) return false;
Play();
return true;
}
void GuiBGM::UpdateState()
{
if (!IsPlaying())
{
if (loopMode == DIR_LOOP)
{
PlayNext();
}
else if (loopMode == RANDOM_BGM)
{
PlayRandom();
}
}
}

View File

@ -1,42 +1,42 @@
/****************************************************************************
* SettingsPrompts
* USB Loader GX 2009
*
* Backgroundmusic
***************************************************************************/
#ifndef _BGM_H_
#define _BGM_H_
#include "libwiigui/gui.h"
enum
{
ONCE = 0, LOOP, RANDOM_BGM, DIR_LOOP
};
class GuiBGM: public GuiSound
{
public:
GuiBGM(const u8 *s, int l, int v);
~GuiBGM();
bool Load(const char *path);
bool LoadStandard();
bool ParsePath(const char * folderpath);
bool PlayNext();
bool PlayPrevious();
bool PlayRandom();
void SetLoop(bool l);
void SetLoop(int l);
void UpdateState();
protected:
void AddEntrie(const char * filename);
void ClearList();
int currentPlaying;
int loopMode;
char * currentPath;
std::vector<char *> PlayList;
};
#endif
/****************************************************************************
* SettingsPrompts
* USB Loader GX 2009
*
* Backgroundmusic
***************************************************************************/
#ifndef _BGM_H_
#define _BGM_H_
#include <vector>
#include "gui_sound.h"
enum
{
ONCE = 0, LOOP, RANDOM_BGM, DIR_LOOP
};
class GuiBGM: public GuiSound
{
public:
GuiBGM(const u8 *s, int l, int v);
~GuiBGM();
bool Load(const char *path);
bool LoadStandard();
bool ParsePath(const char * folderpath);
bool PlayNext();
bool PlayPrevious();
bool PlayRandom();
void SetLoop(u8 l);
void UpdateState();
protected:
void AddEntrie(const char * filename);
void ClearList();
int currentPlaying;
int loopMode;
char * currentPath;
std::vector<char *> PlayList;
};
#endif

View File

@ -0,0 +1,380 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <unistd.h>
#include "libwiigui/gui.h"
#include "utils/uncompress.h"
#include "FileOperations/fileops.h"
#include "SoundHandler.hpp"
#include "WavDecoder.hpp"
#define MAX_SND_VOICES 16
static bool VoiceUsed[MAX_SND_VOICES] =
{
true, false, false, false, false, false,
false, false, false, false, false, false,
false, false, false, false
};
static inline int GetFirstUnusedVoice()
{
for(int i = 1; i < MAX_SND_VOICES; i++)
{
if(VoiceUsed[i] == false)
return i;
}
return -1;
}
extern "C" void SoundCallback(s32 voice)
{
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
return;
if(decoder->IsBufferReady())
{
if(ASND_AddVoice(voice, decoder->GetBuffer(), decoder->GetBufferSize()) == SND_OK)
{
decoder->LoadNext();
SoundHandler::Instance()->ThreadSignal();
}
}
else if(decoder->IsEOF())
{
ASND_StopVoice(voice);
//if(voice == 0)
//MusicPlayer::Instance()->SetPlaybackFinished(true); //see if next music must be played
}
else
{
SoundHandler::Instance()->ThreadSignal();
}
}
GuiSound::GuiSound(const char * filepath)
{
sound = NULL;
length = 0;
voice = GetFirstUnusedVoice();
if(voice > 0)
VoiceUsed[voice] = true;
volume = 255;
SoundEffectLength = 0;
loop = false;
allocated = false;
Load(filepath);
}
GuiSound::GuiSound(const u8 * snd, s32 len, int vol, bool isallocated, int v)
{
sound = NULL;
length = 0;
if(v < 0)
voice = GetFirstUnusedVoice();
else
voice = v;
if(voice > 0)
VoiceUsed[voice] = true;
volume = vol;
SoundEffectLength = 0;
loop = false;
allocated = false;
Load(snd, len, isallocated);
}
GuiSound::~GuiSound()
{
FreeMemory();
if(voice > 0)
VoiceUsed[voice] = false;
}
void GuiSound::FreeMemory()
{
this->Stop();
SoundHandler::Instance()->RemoveDecoder(voice);
if(allocated && sound != NULL)
{
free(sound);
sound = NULL;
allocated = false;
}
SoundEffectLength = 0;
}
bool GuiSound::Load(const char * filepath)
{
FreeMemory();
if(!filepath)
return false;
u32 magic;
FILE * f = fopen(filepath, "rb");
if(!f)
return false;
fread(&magic, 1, 4, f);
fclose(f);
if(magic == 'IMD5')
{
u8 * snd = NULL;
u64 filesize = 0;
LoadFileToMem(filepath, &snd, &filesize);
return Load(snd, filesize, true);
}
SoundHandler::Instance()->AddDecoder(voice, filepath);
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
return false;
if(!decoder->IsBufferReady())
{
SoundHandler::Instance()->RemoveDecoder(voice);
return false;
}
SetLoop(loop);
return true;
}
bool GuiSound::Load(const u8 * snd, s32 len, bool isallocated)
{
FreeMemory();
if(!snd)
return false;
if(!isallocated && *((u32 *) snd) == 'RIFF')
{
return LoadSoundEffect(snd, len);
}
if(*((u32 *) snd) == 'IMD5')
{
UncompressSoundbin(snd, len, isallocated);
}
else
{
sound = (u8 *) snd;
length = len;
allocated = isallocated;
}
SoundHandler::Instance()->AddDecoder(voice, sound, length);
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
return false;
if(!decoder->IsBufferReady())
{
SoundHandler::Instance()->RemoveDecoder(voice);
return false;
}
SetLoop(loop);
return true;
}
bool GuiSound::LoadSoundEffect(const u8 * snd, s32 len)
{
WavDecoder decoder(snd, len);
decoder.Rewind();
u32 done = 0;
sound = (u8 *) malloc(4096);
memset(sound, 0, 4096);
while(1)
{
u8 * tmpsnd = (u8 *) realloc(sound, done+4096);
if(!tmpsnd)
{
free(sound);
sound = NULL;
return false;
}
sound = tmpsnd;
int read = decoder.Read(sound+done, 4096, done);
if(read <= 0)
break;
done += read;
}
sound = (u8 *) realloc(sound, done);
SoundEffectLength = done;
allocated = true;
return true;
}
void GuiSound::Play()
{
if(SoundEffectLength > 0)
{
ASND_StopVoice(voice);
ASND_SetVoice(voice, VOICE_STEREO_16BIT, 32000, 0, sound, SoundEffectLength, volume, volume, NULL);
return;
}
if(IsPlaying())
return;
if(voice < 0 || voice >= 16)
return;
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
return;
if(decoder->IsEOF())
{
ASND_StopVoice(voice);
decoder->ClearBuffer();
decoder->Rewind();
decoder->Decode();
}
u8 * curbuffer = decoder->GetBuffer();
int bufsize = decoder->GetBufferSize();
decoder->LoadNext();
SoundHandler::Instance()->ThreadSignal();
ASND_SetVoice(voice, decoder->GetFormat(), decoder->GetSampleRate(), 0, curbuffer, bufsize, volume, volume, SoundCallback);
}
void GuiSound::Stop()
{
if(voice < 0 || voice >= 16)
return;
ASND_StopVoice(voice);
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
return;
decoder->ClearBuffer();
Rewind();
SoundHandler::Instance()->ThreadSignal();
}
void GuiSound::Pause()
{
if(voice < 0 || voice >= 16)
return;
ASND_StopVoice(voice);
}
void GuiSound::Resume()
{
Play();
}
bool GuiSound::IsPlaying()
{
if(voice < 0 || voice >= 16)
return false;
int result = ASND_StatusVoice(voice);
if(result == SND_WORKING || result == SND_WAITING)
return true;
return false;
}
void GuiSound::SetVolume(int vol)
{
if(voice < 0 || voice >= 16)
return;
if(vol < 0)
return;
volume = 255*(vol/100.0);
ASND_ChangeVolumeVoice(voice, volume, volume);
}
void GuiSound::SetLoop(u8 l)
{
loop = l;
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
return;
decoder->SetLoop(l == 1);
}
void GuiSound::Rewind()
{
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
return;
decoder->Rewind();
}
void GuiSound::UncompressSoundbin(const u8 * snd, int len, bool isallocated)
{
const u8 * file = snd+32;
if(*((u32 *) file) == 'LZ77')
{
u32 size = 0;
sound = uncompressLZ77(file, len-32, &size);
length = size;
}
else
{
length = len-32;
sound = (u8 *) malloc(length);
memcpy(sound, file, length);
}
if(isallocated)
free((u8 *) snd);
allocated = true;
}

View File

@ -0,0 +1,80 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef GUI_SOUND_H_
#define GUI_SOUND_H_
#include <gccore.h>
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
class GuiSound
{
public:
//!Constructor
//!\param sound Pointer to the sound data
//!\param filesize Length of sound data
GuiSound(const char * filepath);
GuiSound(const u8 * sound, int filesize, int volume, bool allocated = false, int voice = -1);
//!Destructor
~GuiSound();
//!Load a file and replace the old one
bool Load(const char * filepath);
//!Load a file and replace the old one
bool Load(const u8 * sound, int filesize, bool allocated = true);
//!For quick playback of the internal soundeffects
bool LoadSoundEffect(const u8 * snd, s32 len);
//!Start sound playback
void Play();
//!Stop sound playback
void Stop();
//!Pause sound playback
void Pause();
//!Resume sound playback
void Resume();
//!Checks if the sound is currently playing
//!\return true if sound is playing, false otherwise
bool IsPlaying();
//!Rewind the music
void Rewind();
//!Set sound volume
//!\param v Sound volume (0-100)
void SetVolume(int v);
//!\param l Loop (true to loop)
void SetLoop(u8 l);
//!Special sound case for sound.bin
void UncompressSoundbin(const u8 * snd, int len, bool isallocated);
protected:
//!Stops sound and frees all memory/closes files
void FreeMemory();
u8 * sound; //!< Pointer to the sound data
int length; //!< Length of sound data
s32 voice; //!< Currently assigned ASND voice channel
int volume; //!< Sound volume (0-100)
u8 loop; //!< Loop sound playback
u32 SoundEffectLength; //!< Check if it is an app soundeffect for faster playback
bool allocated; //!< Is the file allocated or not
};
#endif

View File

@ -9,6 +9,7 @@
#include "libs/libwbfs/libwbfs.h"
#include "language/gettext.h"
#include "bannersound.h"
#include "utils/uncompress.h"
struct IMD5Header
{
@ -67,58 +68,6 @@ static char *u8Filename(const U8Entry *fst, int i)
return (char *) (fst + fst[0].numEntries) + fst[i].nameOffset;
}
inline u32 le32(u32 i)
{
return ((i & 0xFF) << 24) | ((i & 0xFF00) << 8) | ((i & 0xFF0000) >> 8) | ((i & 0xFF000000) >> 24);
}
inline u16 le16(u16 i)
{
return ((i & 0xFF) << 8) | ((i & 0xFF00) >> 8);
}
static u8 *uncompressLZ77(const u8 *inBuf, u32 inLength, u32 &size)
{
u8 *buffer = NULL;
if (inLength <= 0x8 || *((const u32 *) inBuf) != 0x4C5A3737 /*"LZ77"*/|| inBuf[4] != 0x10) return NULL;
u32 uncSize = le32(((const u32 *) inBuf)[1] << 8);
const u8 *inBufEnd = inBuf + inLength;
inBuf += 8;
buffer = new (std::nothrow) u8[uncSize];
if (!buffer) return buffer;
u8 *bufCur = buffer;
u8 *bufEnd = buffer + uncSize;
while (bufCur < bufEnd && inBuf < inBufEnd)
{
u8 flags = *inBuf;
++inBuf;
for (int i = 0; i < 8 && bufCur < bufEnd && inBuf < inBufEnd; ++i)
{
if ((flags & 0x80) != 0)
{
const LZ77Info &info = *(const LZ77Info *) inBuf;
inBuf += sizeof(LZ77Info);
int length = info.length + 3;
if (bufCur - info.offset - 1 < buffer || bufCur + length > bufEnd) return buffer;
memcpy(bufCur, bufCur - info.offset - 1, length);
bufCur += length;
}
else
{
*bufCur = *inBuf;
++inBuf;
++bufCur;
}
flags <<= 1;
}
}
size = uncSize;
return buffer;
}
const u8 *LoadBannerSound(const u8 *discid, u32 *size)
{
if (!discid) return NULL;
@ -181,7 +130,7 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
if (*((u32*) soundChunk) == 0x4C5A3737 /*"LZ77"*/)
{
u32 uncSize = 0;
u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, uncSize);
u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, &uncSize);
if (!uncompressed_data)
{
// WindowPrompt(tr("Can't decompress LZ77"), 0, tr("OK"));
@ -192,7 +141,7 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
free(opening_bnr);
return uncompressed_data;
}
u8 *out = new (std::nothrow) u8[soundChunkSize];
u8 *out = (u8 *) malloc(soundChunkSize);
if (out)
{
memcpy(out, soundChunk, soundChunkSize);

View File

@ -30,10 +30,6 @@ int CheatMenu(const char * gameID)
bool exit = false;
int ret = 1;
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
GuiImage settingsbackground(&settingsbg);
@ -46,14 +42,14 @@ int CheatMenu(const char * gameID)
GuiText backBtnTxt(tr( "Back" ), 22, Theme.prompttext);
backBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
GuiImage backBtnImg(&btnOutline);
GuiButton backBtn(&backBtnImg, &backBtnImg, 2, 3, -140, 400, &trigA, NULL, btnClick2, 1);
GuiButton backBtn(&backBtnImg, &backBtnImg, 2, 3, -140, 400, &trigA, NULL, btnSoundClick2, 1);
backBtn.SetLabel(&backBtnTxt);
backBtn.SetTrigger(&trigB);
GuiText createBtnTxt(tr( "Create" ), 22, Theme.prompttext);
createBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
GuiImage createBtnImg(&btnOutline);
GuiButton createBtn(&createBtnImg, &createBtnImg, 2, 3, 160, 400, &trigA, NULL, btnClick2, 1);
GuiButton createBtn(&createBtnImg, &createBtnImg, 2, 3, 160, 400, &trigA, NULL, btnSoundClick2, 1);
createBtn.SetLabel(&createBtnTxt);
char txtfilename[55];

View File

@ -82,6 +82,7 @@ void USBDevice_deInit()
fatUnmount("USB:/");
//only shutdown libogc usb and not the cios one
__io_usbstorage.shutdown();
__io_usbstorage2.shutdown();
fat_usb_mount = 0;
fat_usb_sec = 0;

View File

@ -71,14 +71,14 @@ extern const u32 credits_button_png_size;
extern const u8 credits_button_over_png[];
extern const u32 credits_button_over_png_size;
extern const u8 button_over_pcm[];
extern const u32 button_over_pcm_size;
extern const u8 button_over_wav[];
extern const u32 button_over_wav_size;
extern const u8 button_click_pcm[];
extern const u32 button_click_pcm_size;
extern const u8 button_click_wav[];
extern const u32 button_click_wav_size;
extern const u8 button_click2_pcm[];
extern const u32 button_click2_pcm_size;
extern const u8 button_click2_wav[];
extern const u32 button_click2_wav_size;
extern const u8 tooltip_left_png[];
extern const u32 tooltip_left_png_size;

View File

@ -208,13 +208,6 @@ int MenuHomebrewBrowse()
int slidedirection = FADE;
/*** Sound Variables ***/
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiSound btnClick1(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
/*** Image Variables ***/
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
@ -273,7 +266,7 @@ int MenuHomebrewBrowse()
backBtnTxt.SetWidescreen(Settings.widescreen);
backBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton backBtn(&backBtnImg, &backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton backBtn(&backBtnImg, &backBtnImg, 2, 3, -180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
backBtn.SetLabel(&backBtnTxt);
backBtn.SetTrigger(&trigB);
@ -285,8 +278,8 @@ int MenuHomebrewBrowse()
GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
GoLeftBtn.SetPosition(25, -25);
GoLeftBtn.SetImage(&GoLeftImg);
GoLeftBtn.SetSoundOver(&btnSoundOver);
GoLeftBtn.SetSoundClick(btnClick2);
GoLeftBtn.SetSoundOver(btnSoundOver);
GoLeftBtn.SetSoundClick(btnSoundClick2);
GoLeftBtn.SetEffectGrow();
GoLeftBtn.SetTrigger(&trigA);
GoLeftBtn.SetTrigger(&trigL);
@ -297,8 +290,8 @@ int MenuHomebrewBrowse()
GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
GoRightBtn.SetPosition(-25, -25);
GoRightBtn.SetImage(&GoRightImg);
GoRightBtn.SetSoundOver(&btnSoundOver);
GoRightBtn.SetSoundClick(btnClick2);
GoRightBtn.SetSoundOver(btnSoundOver);
GoRightBtn.SetSoundClick(btnSoundClick2);
GoRightBtn.SetEffectGrow();
GoRightBtn.SetTrigger(&trigA);
GoRightBtn.SetTrigger(&trigR);
@ -332,8 +325,8 @@ int MenuHomebrewBrowse()
MainButton1.SetLabel(&MainButton1Txt);
MainButton1.SetLabel(&MainButton1DescTxt, 1);
MainButton1.SetLabelOver(&MainButton1DescOverTxt, 1);
MainButton1.SetSoundOver(&btnSoundOver);
MainButton1.SetSoundClick(&btnClick1);
MainButton1.SetSoundOver(btnSoundOver);
MainButton1.SetSoundClick(btnSoundClick);
MainButton1.SetEffectGrow();
MainButton1.SetTrigger(&trigA);
@ -359,8 +352,8 @@ int MenuHomebrewBrowse()
MainButton2.SetLabel(&MainButton2Txt);
MainButton2.SetLabel(&MainButton2DescTxt, 1);
MainButton2.SetLabelOver(&MainButton2DescOverTxt, 1);
MainButton2.SetSoundOver(&btnSoundOver);
MainButton2.SetSoundClick(&btnClick1);
MainButton2.SetSoundOver(btnSoundOver);
MainButton2.SetSoundClick(btnSoundClick);
MainButton2.SetEffectGrow();
MainButton2.SetTrigger(&trigA);
@ -386,8 +379,8 @@ int MenuHomebrewBrowse()
MainButton3.SetLabel(&MainButton3Txt);
MainButton3.SetLabel(&MainButton3DescTxt, 1);
MainButton3.SetLabelOver(&MainButton3DescOverTxt, 1);
MainButton3.SetSoundOver(&btnSoundOver);
MainButton3.SetSoundClick(&btnClick1);
MainButton3.SetSoundOver(btnSoundOver);
MainButton3.SetSoundClick(btnSoundClick);
MainButton3.SetEffectGrow();
MainButton3.SetTrigger(&trigA);
@ -416,8 +409,8 @@ int MenuHomebrewBrowse()
MainButton4.SetLabel(&MainButton4Txt);
MainButton4.SetLabel(&MainButton4DescTxt, 1);
MainButton4.SetLabelOver(&MainButton4DescOverTxt, 1);
MainButton4.SetSoundOver(&btnSoundOver);
MainButton4.SetSoundClick(&btnClick1);
MainButton4.SetSoundOver(btnSoundOver);
MainButton4.SetSoundClick(btnSoundClick);
MainButton4.SetEffectGrow();
MainButton4.SetTrigger(&trigA);
@ -429,8 +422,8 @@ int MenuHomebrewBrowse()
GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
wifiBtn.SetImage(&wifiImg);
wifiBtn.SetPosition(500, 400);
wifiBtn.SetSoundOver(&btnSoundOver);
wifiBtn.SetSoundClick(&btnClick1);
wifiBtn.SetSoundOver(btnSoundOver);
wifiBtn.SetSoundClick(btnSoundClick);
wifiBtn.SetEffectGrow();
wifiBtn.SetAlpha(80);
wifiBtn.SetTrigger(&trigA);
@ -441,8 +434,8 @@ int MenuHomebrewBrowse()
channelBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
channelBtn.SetPosition(440, 400);
channelBtn.SetImage(&channelBtnImg);
channelBtn.SetSoundOver(&btnSoundOver);
channelBtn.SetSoundClick(btnClick2);
channelBtn.SetSoundOver(btnSoundOver);
channelBtn.SetSoundClick(btnSoundClick2);
channelBtn.SetEffectGrow();
channelBtn.SetTrigger(&trigA);

File diff suppressed because it is too large Load Diff

View File

@ -185,7 +185,7 @@ extern "C"
@sel: selects which partitions to copy.
@copy_1_1: makes a 1:1 copy, whenever a game would not use the wii disc format, and some data is hidden outside the filesystem.
*/
u32 wbfs_add_disc(wbfs_t*p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data,
s32 wbfs_add_disc(wbfs_t*p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data,
progress_callback_t spinner, partition_selector_t sel, int copy_1_1);
/*! remove a wiidvd inside a partition */

View File

@ -1,32 +1,32 @@
#ifndef LIBWBFS_GLUE_H
#define LIBWBFS_GLUE_H
#include <gctypes.h>
#define debug_printf(fmt, ...);
#include <stdio.h>
#define wbfs_fatal(x) do { printf("\nwbfs panic: %s\n\n",x); while(1); } while(0)
#define wbfs_error(x) do { printf("\nwbfs error: %s\n\n",x); } while(0)
#include <stdlib.h>
#include <malloc.h>
#define wbfs_malloc(x) malloc(x)
#define wbfs_free(x) free(x)
#define wbfs_ioalloc(x) memalign(32, ((x) + 31) & ~31)
#define wbfs_iofree(x) free(x)
#define wbfs_be16(x) (*((u16*)(x)))
#define wbfs_be32(x) (*((u32*)(x)))
#define wbfs_ntohl(x) (x)
#define wbfs_htonl(x) (x)
#define wbfs_ntohs(x) (x)
#define wbfs_htons(x) (x)
#include <string.h>
#define wbfs_memcmp(x,y,z) memcmp(x,y,z)
#define wbfs_memcpy(x,y,z) memcpy(x,y,z)
#define wbfs_memset(x,y,z) memset(x,y,z)
#endif
#ifndef LIBWBFS_GLUE_H
#define LIBWBFS_GLUE_H
#include <gctypes.h>
#define debug_printf(fmt, ...);
#include <stdio.h>
#define wbfs_fatal(x) do { printf("\nwbfs panic: %s\n\n",x); return; } while(0)
#define wbfs_error(x) do { printf("\nwbfs error: %s\n\n",x); } while(0)
#include <stdlib.h>
#include <malloc.h>
#define wbfs_malloc(x) malloc(x)
#define wbfs_free(x) free(x)
#define wbfs_ioalloc(x) memalign(32, ((x) + 31) & ~31)
#define wbfs_iofree(x) free(x)
#define wbfs_be16(x) (*((u16*)(x)))
#define wbfs_be32(x) (*((u32*)(x)))
#define wbfs_ntohl(x) (x)
#define wbfs_htonl(x) (x)
#define wbfs_ntohs(x) (x)
#define wbfs_htons(x) (x)
#include <string.h>
#define wbfs_memcmp(x,y,z) memcmp(x,y,z)
#define wbfs_memcpy(x,y,z) memcpy(x,y,z)
#define wbfs_memset(x,y,z) memset(x,y,z)
#endif

View File

@ -46,8 +46,15 @@
#include "filelist.h"
#include "input.h"
#include "OptionList.hpp"
#include "SoundOperations/gui_sound.h"
#include "SoundOperations/gui_bgm.h"
//! Frequently used variables
extern FreeTypeGX *fontSystem;
extern GuiSound *btnSoundClick;
extern GuiSound *btnSoundClick2;
extern GuiSound *btnSoundOver;
extern GuiBGM *bgMusic;
#define SCROLL_INITIAL_DELAY 20
#define SCROLL_LOOP_DELAY 3
@ -108,70 +115,6 @@ typedef struct _paddata
#define EFFECT_ROCK_VERTICLE 1024
#define EFFECT_GOROUND 2048
#define MAX_SND_VOICES 16
class GuiSoundDecoder;
class GuiSound
{
public:
//!Constructor
//!\param s Pointer to the sound data
//!\param l Length of sound data
//!\param v Sound volume (0-100)
//!\param r RAW PCM Sound, when no decoder is found then try to play as raw-pcm
//!\param a true--> Pointer to the sound data is allocated with new u8[...]
//!\ GuiSound will be destroy the buffer if it no more needed
//!\ false-> sound data buffer has to live just as long as GuiSound
GuiSound(const u8 *s, int l, int v = 100, bool r = true, bool a = false);
//!Constructor
//!\param p Path to the sound data
//!\param v Sound volume (0-100)
GuiSound(const char *p, int v = 100);
//!Load - stop playing and load the new sound data
//! if load not failed replace the current with new sound data
//! otherwise the current date will not changed
//!\params same as by Constructors
//!\return true ok / false = failed
bool Load(const u8 *s, int l, bool r = false, bool a = false);
bool Load(const char *p);
//!Destructor
~GuiSound();
//!Start sound playback
void Play();
//!Stop sound playback
void Stop();
//!Pause sound playback
void Pause();
//!Resume sound playback
void Resume();
//!Checks if the sound is currently playing
//!\return true if sound is playing, false otherwise
bool IsPlaying();
//!Set sound volume
//!\param v Sound volume (0-100)
void SetVolume(int v);
//!Set the sound to loop playback (only applies to OGG)
//!\param l Loop (true to loop)
void SetLoop(bool l);
//!Get the playing time in ms for that moment (only applies to OGG)
protected:
s32 voice; // used asnd-voice
u8 *play_buffer[3]; // trpple-playbuffer
int buffer_nr; // current playbuffer
int buffer_pos; // current idx to write in buffer
bool buffer_ready; // buffer is filled and ready
bool buffer_eof; // no mor datas - will stop playing
bool loop; // play looped
s32 volume; // volume
GuiSoundDecoder *decoder;
void DecoderCallback();
void PlayerCallback();
friend void *GuiSoundDecoderThread(void *args);
friend void GuiSoundPlayerCallback(s32 Voice);
};
//!Menu input trigger management. Determine if action is neccessary based on input data by comparing controller input data to a specific trigger element.
class GuiTrigger
{

View File

@ -51,10 +51,10 @@ GuiButton::GuiButton(int w, int h)
GuiButton::GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x, int y, GuiTrigger* trig,
GuiSound* sndOver, GuiSound* sndClick, u8 grow)
{
width = img->GetWidth();
height = img->GetHeight();
width = img ? img->GetWidth() : 0;
height = img ? img->GetHeight() : 0;
image = img;
image->SetParent(this);
if(image) image->SetParent(this);
imageOver = imgOver;
if (imageOver) imageOver->SetParent(this);
imageHold = NULL;
@ -97,10 +97,10 @@ GuiButton::GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x,
GuiButton::GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x, int y, GuiTrigger* trig,
GuiSound* sndOver, GuiSound* sndClick, u8 grow, GuiTooltip* tt, int ttx, int tty, int h_align, int v_align)
{
width = img->GetWidth();
height = img->GetHeight();
width = img ? img->GetWidth() : 0;
height = img ? img->GetHeight() : 0;
image = img;
image->SetParent(this);
if(image) image->SetParent(this);
imageOver = imgOver;
if (imageOver) imageOver->SetParent(this);
imageHold = NULL;
@ -139,9 +139,12 @@ GuiButton::GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x,
}
toolTip = tt;
toolTip->SetParent(this);
toolTip->SetAlignment(h_align, v_align);
toolTip->SetPosition(ttx, tty);
if(toolTip)
{
toolTip->SetParent(this);
toolTip->SetAlignment(h_align, v_align);
toolTip->SetPosition(ttx, tty);
}
time1 = time2 = 0;
}

View File

@ -13,6 +13,7 @@
#include "../settings/CSettings.h"
#include "gui_customoptionbrowser.h"
#include "themes/CTheme.h"
#include "menu.h"
#include <unistd.h>
@ -26,7 +27,6 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, con
width = w;
height = h;
options = l;
size = PAGESIZE;
scrollbaron = scrollon;
selectable = true;
listOffset = this->FindMenuItem(-1, 1);
@ -38,7 +38,6 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, con
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigHeldA = new GuiTrigger;
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
bgOptions = Resources::GetImageData(custombg);
@ -104,14 +103,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, con
scrollbarBoxBtn->SetHoldable(true);
scrollbarBoxBtn->SetTrigger(trigHeldA);
optionIndex = new int[size];
optionVal = new GuiText *[size];
optionValOver = new GuiText *[size];
optionBtn = new GuiButton *[size];
optionTxt = new GuiText *[size];
optionBg = new GuiImage *[size];
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
optionTxt[i] = new GuiText(options->GetName(i), 20, Theme.settingstext);
optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
@ -170,9 +162,8 @@ GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
delete trigA;
delete trigHeldA;
delete btnSoundClick;
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
delete optionTxt[i];
delete optionVal[i];
@ -180,20 +171,13 @@ GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
delete optionBg[i];
delete optionBtn[i];
}
delete[] optionIndex;
delete[] optionVal;
delete[] optionValOver;
delete[] optionBtn;
delete[] optionTxt;
delete[] optionBg;
}
void GuiCustomOptionBrowser::SetFocus(int f)
{
LOCK( this );
focus = f;
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
optionBtn[i]->ResetState();
if (f == 1) optionBtn[selectedItem]->SetState(STATE_SELECTED);
@ -201,14 +185,13 @@ void GuiCustomOptionBrowser::SetFocus(int f)
void GuiCustomOptionBrowser::ResetState()
{
LOCK( this );
if (state != STATE_DISABLED)
{
state = STATE_DEFAULT;
stateChan = -1;
}
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
optionBtn[i]->ResetState();
}
@ -217,7 +200,7 @@ void GuiCustomOptionBrowser::ResetState()
int GuiCustomOptionBrowser::GetClickedOption()
{
int found = -1;
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() == STATE_CLICKED)
{
@ -232,7 +215,7 @@ int GuiCustomOptionBrowser::GetClickedOption()
int GuiCustomOptionBrowser::GetSelectedOption()
{
int found = -1;
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() == STATE_SELECTED)
{
@ -245,7 +228,7 @@ int GuiCustomOptionBrowser::GetSelectedOption()
void GuiCustomOptionBrowser::SetClickable(bool enable)
{
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
optionBtn[i]->SetClickable(enable);
}
@ -284,14 +267,13 @@ int GuiCustomOptionBrowser::FindMenuItem(int currentItem, int direction)
*/
void GuiCustomOptionBrowser::Draw()
{
LOCK( this );
if (!this->IsVisible()) return;
bgOptionsImg->Draw();
int next = listOffset;
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
if (next >= 0)
{
@ -313,12 +295,12 @@ void GuiCustomOptionBrowser::Draw()
void GuiCustomOptionBrowser::UpdateListEntries()
{
scrollbaron = options->GetLength() > size;
scrollbaron = options->GetLength() > PAGESIZE;
if (listOffset < 0) listOffset = this->FindMenuItem(-1, 1);
int next = listOffset;
int maxNameWidth = 0;
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
if (next >= 0)
{
@ -343,7 +325,7 @@ void GuiCustomOptionBrowser::UpdateListEntries()
}
}
if (coL2 < (24 + maxNameWidth + 16)) coL2 = 24 + maxNameWidth + 16;
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() != STATE_DISABLED)
{
@ -358,7 +340,6 @@ void GuiCustomOptionBrowser::UpdateListEntries()
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{
LOCK( this );
int next, prev, lang = options->GetLength();
if (state == STATE_DISABLED || !t) return;
@ -384,7 +365,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
if (buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN)
{
for (int i = 0; i < size; i++)
for (int i = 0; i < PAGESIZE; i++)
{
if (next >= 0) next = this->FindMenuItem(next, 1);
@ -418,7 +399,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
if (next >= 0)
{
if (selectedItem == size - 1)
if (selectedItem == PAGESIZE - 1)
{
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
@ -460,7 +441,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
if (next >= 0)
{
if (selectedItem == size - 1)
if (selectedItem == PAGESIZE - 1)
{
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
@ -506,7 +487,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
}
if (scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid
&& options->GetLength() > size)
&& options->GetLength() > PAGESIZE)
{
scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, 0);
@ -519,10 +500,10 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
listOffset = 0;
selectedItem = 0;
}
else if (listOffset + size >= lang)
else if (listOffset + PAGESIZE >= lang)
{
listOffset = lang - size;
selectedItem = size - 1;
listOffset = lang - PAGESIZE;
selectedItem = PAGESIZE - 1;
}
}
int positionbar = 237 * (listOffset + selectedItem) / lang;
@ -532,17 +513,17 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
if (t->Right())
{
if (listOffset < lang && lang > size)
if (listOffset < lang && lang > PAGESIZE)
{
listOffset = listOffset + size;
if (listOffset + size >= lang) listOffset = lang - size;
listOffset = listOffset + PAGESIZE;
if (listOffset + PAGESIZE >= lang) listOffset = lang - PAGESIZE;
}
}
else if (t->Left())
{
if (listOffset > 0)
{
listOffset = listOffset - size;
listOffset = listOffset - PAGESIZE;
if (listOffset < 0) listOffset = 0;
}
}

View File

@ -1,4 +1,8 @@
#ifndef GUI_CUSTOMBROWSER_H_
#define GUI_CUSTOMBROWSER_H_
#include "gui.h"
#include <vector>
//!Display a list of menu options
class GuiCustomOptionBrowser: public GuiElement
@ -20,17 +24,16 @@ class GuiCustomOptionBrowser: public GuiElement
void UpdateListEntries();
int selectedItem;
int listOffset;
int size;
int coL2;
int scrollbaron;
OptionList * options;
int * optionIndex;
GuiButton ** optionBtn;
GuiText ** optionTxt;
GuiText ** optionVal;
GuiText ** optionValOver;
GuiImage ** optionBg;
int optionIndex[PAGESIZE];
GuiButton * optionBtn[PAGESIZE];
GuiText * optionTxt[PAGESIZE];
GuiText * optionVal[PAGESIZE];
GuiText * optionValOver[PAGESIZE];
GuiImage * optionBg[PAGESIZE];
GuiButton * arrowUpBtn;
GuiButton * arrowDownBtn;
@ -55,7 +58,8 @@ class GuiCustomOptionBrowser: public GuiElement
GuiImageData * scrollbarBox;
GuiImageData * scrollbarBoxOver;
GuiSound * btnSoundClick;
GuiTrigger * trigA;
GuiTrigger * trigHeldA;
};
#endif

View File

@ -32,18 +32,15 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
trigHeldA = new GuiTrigger;
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
bgFileSelection = new GuiImageData(Resources::GetFile("bg_browser.png"), Resources::GetFileSize("bg_browser.png"));
bgFileSelectionImg = new GuiImage(bgFileSelection);
bgFileSelectionImg->SetParent(this);
bgFileSelectionImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
bgFileSelectionEntry = Resources::GetImageData("bg_browser_selection.png");
fileFolder = Resources::GetImageData("icon_folder.png");
scrollbar = Resources::GetImageData("scrollbar.png");
scrollbarImg = new GuiImage(scrollbar);
scrollbarImg->SetParent(this);
@ -160,8 +157,6 @@ GuiFileBrowser::~GuiFileBrowser()
delete arrowUp;
delete scrollbarBox;
delete btnSoundOver;
delete btnSoundClick;
delete trigHeldA;
delete trigA;

View File

@ -17,6 +17,7 @@
#include "settings/GameTitles.h"
#include "usbloader/GameList.h"
#include "themes/CTheme.h"
#include "menu.h"
#include <string.h>
#include <sstream>
@ -41,7 +42,6 @@ GuiGameBrowser::GuiGameBrowser(int w, int h, int selected, int offset)
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigHeldA = new GuiTrigger;
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
bgGames = Resources::GetImageData("bg_options.png");
newGames = Resources::GetImageData("new.png");
@ -182,7 +182,6 @@ GuiGameBrowser::~GuiGameBrowser()
delete trigA;
delete trigHeldA;
delete btnSoundClick;
for (int i = 0; i < pagesize; i++)
{

View File

@ -1,65 +1,64 @@
#ifndef _GUIGAMEBROWSER_H_
#define _GUIGAMEBROWSER_H_
#include "gui.h"
#include "../usbloader/disc.h"
class GuiGameBrowser: public GuiElement
{
public:
GuiGameBrowser(int w, int h, int selected = 0, int offset = 0);
~GuiGameBrowser();
int FindMenuItem(int c, int d);
int GetClickedOption();
int GetSelectedOption();
void ResetState();
void SetFocus(int f);
void Draw();
void Update(GuiTrigger * t);
int GetOffset();
void Reload();
//GuiText * optionVal[PAGESIZE];
protected:
void UpdateListEntries();
int selectedItem;
int listOffset;
int scrollbaron;
int pagesize;
int maxTextWidth;
int * gameIndex;
GuiButton ** game;
GuiText ** gameTxt;
GuiText ** gameTxtOver;
GuiImage ** gameBg;
GuiImage ** newImg;
GuiButton * arrowUpBtn;
GuiButton * arrowDownBtn;
GuiButton * scrollbarBoxBtn;
GuiImage * bgGameImg;
GuiImage * scrollbarImg;
GuiImage * arrowDownImg;
GuiImage * arrowDownOverImg;
GuiImage * arrowUpImg;
GuiImage * arrowUpOverImg;
GuiImage * scrollbarBoxImg;
GuiImage * scrollbarBoxOverImg;
GuiImageData * bgGames;
GuiImageData * bgGamesEntry;
GuiImageData * newGames;
GuiImageData * scrollbar;
GuiImageData * arrowDown;
GuiImageData * arrowDownOver;
GuiImageData * arrowUp;
GuiImageData * arrowUpOver;
GuiImageData * scrollbarBox;
GuiImageData * scrollbarBoxOver;
GuiSound * btnSoundClick;
GuiTrigger * trigA;
GuiTrigger * trigHeldA;
};
#endif
#ifndef _GUIGAMEBROWSER_H_
#define _GUIGAMEBROWSER_H_
#include "gui.h"
#include "../usbloader/disc.h"
class GuiGameBrowser: public GuiElement
{
public:
GuiGameBrowser(int w, int h, int selected = 0, int offset = 0);
~GuiGameBrowser();
int FindMenuItem(int c, int d);
int GetClickedOption();
int GetSelectedOption();
void ResetState();
void SetFocus(int f);
void Draw();
void Update(GuiTrigger * t);
int GetOffset();
void Reload();
//GuiText * optionVal[PAGESIZE];
protected:
void UpdateListEntries();
int selectedItem;
int listOffset;
int scrollbaron;
int pagesize;
int maxTextWidth;
int * gameIndex;
GuiButton ** game;
GuiText ** gameTxt;
GuiText ** gameTxtOver;
GuiImage ** gameBg;
GuiImage ** newImg;
GuiButton * arrowUpBtn;
GuiButton * arrowDownBtn;
GuiButton * scrollbarBoxBtn;
GuiImage * bgGameImg;
GuiImage * scrollbarImg;
GuiImage * arrowDownImg;
GuiImage * arrowDownOverImg;
GuiImage * arrowUpImg;
GuiImage * arrowUpOverImg;
GuiImage * scrollbarBoxImg;
GuiImage * scrollbarBoxOverImg;
GuiImageData * bgGames;
GuiImageData * bgGamesEntry;
GuiImageData * newGames;
GuiImageData * scrollbar;
GuiImageData * arrowDown;
GuiImageData * arrowDownOver;
GuiImageData * arrowUp;
GuiImageData * arrowUpOver;
GuiImageData * scrollbarBox;
GuiImageData * scrollbarBoxOver;
GuiTrigger * trigA;
GuiTrigger * trigHeldA;
};
#endif

View File

@ -70,9 +70,6 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, const char *themePath, const u8 *
trigMinus = new GuiTrigger;
trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
btnSoundClick = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
imgLeft = Resources::GetImageData("startgame_arrow_left.png");
imgRight = Resources::GetImageData("startgame_arrow_right.png");
@ -164,8 +161,6 @@ GuiGameCarousel::~GuiGameCarousel()
delete trigR;
delete trigPlus;
delete trigMinus;
delete btnSoundClick;
delete btnSoundOver;
delete gamename;
for (int i = 0; i < pagesize; i++)

View File

@ -1,54 +1,52 @@
#ifndef _GUIGAMECAROUSEL_H_
#define _GUIGAMECAROUSEL_H_
#include "gui.h"
#include "../usbloader/disc.h"
class GuiImageAsync;
class GuiGameCarousel: public GuiElement
{
public:
GuiGameCarousel(int w, int h, const char *themePath, const u8 *imagebg, int imagebgsize, int selected = 0, int offset = 0);
~GuiGameCarousel();
int FindMenuItem(int c, int d);
int GetClickedOption();
int GetSelectedOption();
void ResetState();
void SetFocus(int f);
void Draw();
void Update(GuiTrigger * t);
int GetOffset();
void Reload();
//GuiText * optionVal[PAGESIZE];
protected:
GuiImageData noCover;
int selectedItem;
int listOffset;
int scrollbaron;
int pagesize;
int speed;
int clickedItem;
int * gameIndex;
GuiButton ** game;
GuiImageAsync ** coverImg;
GuiText * gamename;
GuiButton * btnRight;
GuiButton * btnLeft;
GuiImage * btnLeftImg;
GuiImage * btnRightImg;
GuiImageData * imgLeft;
GuiImageData * imgRight;
GuiSound * btnSoundOver;
GuiSound * btnSoundClick;
GuiTrigger * trigA;
GuiTrigger * trigL;
GuiTrigger * trigR;
GuiTrigger * trigPlus;
GuiTrigger * trigMinus;
};
#endif
#ifndef _GUIGAMECAROUSEL_H_
#define _GUIGAMECAROUSEL_H_
#include "gui.h"
#include "../usbloader/disc.h"
class GuiImageAsync;
class GuiGameCarousel: public GuiElement
{
public:
GuiGameCarousel(int w, int h, const char *themePath, const u8 *imagebg, int imagebgsize, int selected = 0, int offset = 0);
~GuiGameCarousel();
int FindMenuItem(int c, int d);
int GetClickedOption();
int GetSelectedOption();
void ResetState();
void SetFocus(int f);
void Draw();
void Update(GuiTrigger * t);
int GetOffset();
void Reload();
//GuiText * optionVal[PAGESIZE];
protected:
GuiImageData noCover;
int selectedItem;
int listOffset;
int scrollbaron;
int pagesize;
int speed;
int clickedItem;
int * gameIndex;
GuiButton ** game;
GuiImageAsync ** coverImg;
GuiText * gamename;
GuiButton * btnRight;
GuiButton * btnLeft;
GuiImage * btnLeftImg;
GuiImage * btnRightImg;
GuiImageData * imgLeft;
GuiImageData * imgRight;
GuiTrigger * trigA;
GuiTrigger * trigL;
GuiTrigger * trigR;
GuiTrigger * trigPlus;
GuiTrigger * trigMinus;
};
#endif

View File

@ -238,9 +238,6 @@ GuiGameGrid::GuiGameGrid(int w, int h, const char *themePath, const u8 *imagebg,
trigMinus = new GuiTrigger;
trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
btnSoundClick = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
int btnHeight = (int) lround(sqrt(RADIUS * RADIUS - 90000) - RADIUS - 50);
// Button Left
@ -303,8 +300,6 @@ GuiGameGrid::~GuiGameGrid()
delete trigMinus;
delete trig1;
delete trig2;
delete btnSoundClick;
delete btnSoundOver;
for (int i = pagesize - 1; i >= 0; i--)
{

View File

@ -45,8 +45,6 @@ class GuiGameGrid: public GuiElement
GuiImageData * imgLeft;
GuiImageData * imgRight;
GuiSound * btnSoundOver;
GuiSound * btnSoundClick;
GuiTrigger * trigA;
GuiTrigger * trigL;
GuiTrigger * trigR;

View File

@ -13,6 +13,7 @@
#include "../settings/CSettings.h"
#include <stdio.h>
#include <string.h>
#include "menu.h"
/**
* Constructor for the GuiKeyboard class.
*/
@ -136,8 +137,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyLarge = new GuiImageData(keyboard_largekey_over_png, keyboard_largekey_over_png_size);
keyLargeOver = new GuiImageData(keyboard_largekey_over_png, keyboard_largekey_over_png_size);
keySoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger;
@ -161,11 +160,9 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyBackText = new GuiText("Back", 20, ( GXColor )
{ 0, 0, 0, 0xff});
}
//GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x, int y, GuiTrigger* trig, GuiSound* sndOver, GuiSound* sndClick, u8 grow);
//keyBack = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyBack = new GuiButton(keyBackImg, keyBackOverImg, 0, 3, 11 * 42 + 40 + eurocheck, 0 * 42 + 120, trigA,
keySoundOver, keySoundClick, 1);
btnSoundOver, btnSoundClick, 1);
//keyBack->SetImage(keyBackImg);
//keyBack->SetImageOver(keyBackOverImg);
keyBack->SetLabel(keyBackText);
@ -366,8 +363,6 @@ GuiKeyboard::~GuiKeyboard()
delete keyMediumOver;
delete keyLarge;
delete keyLargeOver;
delete keySoundOver;
delete keySoundClick;
delete trigA;
delete trigB;

View File

@ -1,205 +1,201 @@
/****************************************************************************
* USB Loader GX
*
* r-win 2009
*
* gui_numpad.cpp
*
* GUI class definitions
***************************************************************************/
#include "gui.h"
#include "../main.h"
#include "../settings/CSettings.h"
#include <stdio.h>
#include <string.h>
/**
* Constructor for the GuiNumpad class.
*/
#define SAFEFREE(p) if(p){free(p);p=NULL;}
GuiNumpad::GuiNumpad(char * t, u32 max)
{
width = 400;
height = 370;
selectable = true;
focus = 0; // allow focus
alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE;
kbtextmaxlen = max > sizeof(kbtextstr) ? sizeof(kbtextstr) : max; // limit max up to sizeof(kbtextstr)
// strlcpy(kbtextstr, t, kbtextmaxlen);
strncpy(kbtextstr, t, kbtextmaxlen); // strncpy is needed to fill the rest with \0
kbtextstr[sizeof(kbtextstr) - 1] = 0; // terminate with \0
char thekeys[11] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '\0', '0' };
memcpy(keys, thekeys, sizeof(thekeys));
keyTextbox = new GuiImageData(keyboard_textbox_png, keyboard_textbox_png_size);
keyTextboxImg = new GuiImage(keyTextbox);
keyTextboxImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
keyTextboxImg->SetPosition(0, 40);//(0,0);
this->Append(keyTextboxImg);
kbText = new GuiText(kbtextstr, 20, ( GXColor )
{ 0, 0, 0, 0xff});
kbText->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
kbText->SetPosition(0, 53);//(0, 13);
kbText->SetPassChar('*');
this->Append(kbText);
keyMedium = new GuiImageData(keyboard_mediumkey_over_png, keyboard_mediumkey_over_png_size);
keyMediumOver = new GuiImageData(keyboard_mediumkey_over_png, keyboard_mediumkey_over_png_size);
keySoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger;
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver);
keyBackText = new GuiText("Back", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyBack = new GuiButton(keyBackImg, keyBackOverImg, ALIGN_CENTRE, ALIGN_MIDDLE, 90, 80, trigA, keySoundOver,
keySoundClick, 1);
keyBack->SetLabel(keyBackText);
keyBack->SetTrigger(trigB);
this->Append(keyBack);
keyClearImg = new GuiImage(keyMedium);
keyClearOverImg = new GuiImage(keyMediumOver);
keyClearText = new GuiText("Clear", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyClear = new GuiButton(keyClearImg, keyClearOverImg, ALIGN_CENTRE, ALIGN_MIDDLE, -90, 80, trigA, keySoundOver,
keySoundClick, 1);
keyClear->SetLabel(keyClearText);
this->Append(keyClear);
char txt[2] = { 0, 0 };
for (int i = 0; i < 11; i++)
{
if (keys[i] != '\0')
{
int col = i % 3;
int row = i / 3;
keyImg[i] = new GuiImage(keyMedium);
keyImgOver[i] = new GuiImage(keyMediumOver);
txt[0] = keys[i];
keyTxt[i] = new GuiText(txt, 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyTxt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
keyTxt[i]->SetPosition(0, -10);
keyBtn[i] = new GuiButton(keyImg[i], keyImgOver[i], ALIGN_CENTRE, ALIGN_MIDDLE, -90 + 90 * col, -70 + 50
* row, trigA, keySoundOver, keySoundClick, 1);
keyBtn[i]->SetLabel(keyTxt[i]);
this->Append(keyBtn[i]);
}
}
}
/**
* Destructor for the GuiKeyboard class.
*/
GuiNumpad::~GuiNumpad()
{
SAFEFREE( kbText )
SAFEFREE( keyTextbox )
SAFEFREE( keyTextboxImg )
SAFEFREE( keyBackText )
SAFEFREE( keyBackImg )
SAFEFREE( keyBackOverImg )
SAFEFREE( keyBack )
SAFEFREE( keyClear )
SAFEFREE( keyClearImg )
SAFEFREE( keyClearOverImg )
SAFEFREE( keyClearText )
SAFEFREE( keyMedium )
SAFEFREE( keyMediumOver )
SAFEFREE( keySoundOver )
SAFEFREE( keySoundClick )
SAFEFREE( trigA )
SAFEFREE( trigB )
for (int i = 0; i < 11; i++)
{
if (keys[i] != '\0')
{
SAFEFREE( keyImg[i] )
SAFEFREE( keyImgOver[i] )
SAFEFREE( keyTxt[i] )
SAFEFREE( keyBtn[i] )
}
}
}
void GuiNumpad::Update(GuiTrigger * t)
{
LOCK( this );
if (_elements.size() == 0 || (state == STATE_DISABLED && parentElement)) return;
for (u8 i = 0; i < _elements.size(); i++)
{
try
{
_elements.at(i)->Update(t);
}
catch (const std::exception& e)
{
}
}
if (keyBack->GetState() == STATE_CLICKED)
{
if (strlen(kbtextstr) > 0)
{
kbtextstr[strlen(kbtextstr) - 1] = 0;
kbText->SetText(kbtextstr);
}
keyBack->SetState(STATE_SELECTED, t->chan);
}
else if (keyClear->GetState() == STATE_CLICKED)
{
memset(kbtextstr, 0, sizeof(kbtextstr));
kbText->SetText(kbtextstr);
keyClear->SetState(STATE_SELECTED, t->chan);
}
char txt[2] = { 0, 0 };
for (int i = 0; i < 11; i++)
{
if (keys[i] != '\0')
{
if (keyBtn[i]->GetState() == STATE_CLICKED)
{
txt[0] = keys[i];
if (strlen(kbtextstr) < kbtextmaxlen - 1) // -1 --> kbtextmaxlen means with term. '\0'
{
kbtextstr[strlen(kbtextstr)] = txt[0];
kbText->SetText(kbtextstr);
}
keyBtn[i]->SetState(STATE_SELECTED, t->chan);
}
}
}
kbText->SetPosition(0, 53);
this->ToggleFocus(t);
if (focus) // only send actions to this window if it's in focus
{
// pad/joystick navigation
if (t->Right())
this->MoveSelectionHor(1);
else if (t->Left())
this->MoveSelectionHor(-1);
else if (t->Down())
this->MoveSelectionVert(1);
else if (t->Up()) this->MoveSelectionVert(-1);
}
}
/****************************************************************************
* USB Loader GX
*
* r-win 2009
*
* gui_numpad.cpp
*
* GUI class definitions
***************************************************************************/
#include "gui.h"
#include "../main.h"
#include "../settings/CSettings.h"
#include <stdio.h>
#include <string.h>
/**
* Constructor for the GuiNumpad class.
*/
#define SAFEFREE(p) if(p){free(p);p=NULL;}
GuiNumpad::GuiNumpad(char * t, u32 max)
{
width = 400;
height = 370;
selectable = true;
focus = 0; // allow focus
alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE;
kbtextmaxlen = max > sizeof(kbtextstr) ? sizeof(kbtextstr) : max; // limit max up to sizeof(kbtextstr)
// strlcpy(kbtextstr, t, kbtextmaxlen);
strncpy(kbtextstr, t, kbtextmaxlen); // strncpy is needed to fill the rest with \0
kbtextstr[sizeof(kbtextstr) - 1] = 0; // terminate with \0
char thekeys[11] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '\0', '0' };
memcpy(keys, thekeys, sizeof(thekeys));
keyTextbox = new GuiImageData(keyboard_textbox_png, keyboard_textbox_png_size);
keyTextboxImg = new GuiImage(keyTextbox);
keyTextboxImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
keyTextboxImg->SetPosition(0, 40);//(0,0);
this->Append(keyTextboxImg);
kbText = new GuiText(kbtextstr, 20, ( GXColor )
{ 0, 0, 0, 0xff});
kbText->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
kbText->SetPosition(0, 53);//(0, 13);
kbText->SetPassChar('*');
this->Append(kbText);
keyMedium = new GuiImageData(keyboard_mediumkey_over_png, keyboard_mediumkey_over_png_size);
keyMediumOver = new GuiImageData(keyboard_mediumkey_over_png, keyboard_mediumkey_over_png_size);
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger;
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver);
keyBackText = new GuiText("Back", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyBack = new GuiButton(keyBackImg, keyBackOverImg, ALIGN_CENTRE, ALIGN_MIDDLE, 90, 80, trigA, keySoundOver,
keySoundClick, 1);
keyBack->SetLabel(keyBackText);
keyBack->SetTrigger(trigB);
this->Append(keyBack);
keyClearImg = new GuiImage(keyMedium);
keyClearOverImg = new GuiImage(keyMediumOver);
keyClearText = new GuiText("Clear", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyClear = new GuiButton(keyClearImg, keyClearOverImg, ALIGN_CENTRE, ALIGN_MIDDLE, -90, 80, trigA, keySoundOver,
keySoundClick, 1);
keyClear->SetLabel(keyClearText);
this->Append(keyClear);
char txt[2] = { 0, 0 };
for (int i = 0; i < 11; i++)
{
if (keys[i] != '\0')
{
int col = i % 3;
int row = i / 3;
keyImg[i] = new GuiImage(keyMedium);
keyImgOver[i] = new GuiImage(keyMediumOver);
txt[0] = keys[i];
keyTxt[i] = new GuiText(txt, 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyTxt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
keyTxt[i]->SetPosition(0, -10);
keyBtn[i] = new GuiButton(keyImg[i], keyImgOver[i], ALIGN_CENTRE, ALIGN_MIDDLE, -90 + 90 * col, -70 + 50
* row, trigA, keySoundOver, keySoundClick, 1);
keyBtn[i]->SetLabel(keyTxt[i]);
this->Append(keyBtn[i]);
}
}
}
/**
* Destructor for the GuiKeyboard class.
*/
GuiNumpad::~GuiNumpad()
{
SAFEFREE( kbText )
SAFEFREE( keyTextbox )
SAFEFREE( keyTextboxImg )
SAFEFREE( keyBackText )
SAFEFREE( keyBackImg )
SAFEFREE( keyBackOverImg )
SAFEFREE( keyBack )
SAFEFREE( keyClear )
SAFEFREE( keyClearImg )
SAFEFREE( keyClearOverImg )
SAFEFREE( keyClearText )
SAFEFREE( keyMedium )
SAFEFREE( keyMediumOver )
SAFEFREE( trigA )
SAFEFREE( trigB )
for (int i = 0; i < 11; i++)
{
if (keys[i] != '\0')
{
SAFEFREE( keyImg[i] )
SAFEFREE( keyImgOver[i] )
SAFEFREE( keyTxt[i] )
SAFEFREE( keyBtn[i] )
}
}
}
void GuiNumpad::Update(GuiTrigger * t)
{
LOCK( this );
if (_elements.size() == 0 || (state == STATE_DISABLED && parentElement)) return;
for (u8 i = 0; i < _elements.size(); i++)
{
try
{
_elements.at(i)->Update(t);
}
catch (const std::exception& e)
{
}
}
if (keyBack->GetState() == STATE_CLICKED)
{
if (strlen(kbtextstr) > 0)
{
kbtextstr[strlen(kbtextstr) - 1] = 0;
kbText->SetText(kbtextstr);
}
keyBack->SetState(STATE_SELECTED, t->chan);
}
else if (keyClear->GetState() == STATE_CLICKED)
{
memset(kbtextstr, 0, sizeof(kbtextstr));
kbText->SetText(kbtextstr);
keyClear->SetState(STATE_SELECTED, t->chan);
}
char txt[2] = { 0, 0 };
for (int i = 0; i < 11; i++)
{
if (keys[i] != '\0')
{
if (keyBtn[i]->GetState() == STATE_CLICKED)
{
txt[0] = keys[i];
if (strlen(kbtextstr) < kbtextmaxlen - 1) // -1 --> kbtextmaxlen means with term. '\0'
{
kbtextstr[strlen(kbtextstr)] = txt[0];
kbText->SetText(kbtextstr);
}
keyBtn[i]->SetState(STATE_SELECTED, t->chan);
}
}
}
kbText->SetPosition(0, 53);
this->ToggleFocus(t);
if (focus) // only send actions to this window if it's in focus
{
// pad/joystick navigation
if (t->Right())
this->MoveSelectionHor(1);
else if (t->Left())
this->MoveSelectionHor(-1);
else if (t->Down())
this->MoveSelectionVert(1);
else if (t->Up()) this->MoveSelectionVert(-1);
}
}

View File

@ -38,8 +38,6 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l, const char *ima
trigHeldA = new GuiTrigger;
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
bgOptions = Resources::GetImageData(imagebg);
bgOptionsImg = new GuiImage(bgOptions);
bgOptionsImg->SetParent(this);
@ -152,7 +150,6 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l, const char *ima
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigHeldA = new GuiTrigger;
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
bgOptions = Resources::GetImageData(imagebg);
@ -276,7 +273,6 @@ GuiOptionBrowser::~GuiOptionBrowser()
loaded = 0;
delete trigA;
delete btnSoundClick;
// delete optionBg;
for (int i = 0; i < PAGESIZE; i++)

View File

@ -31,9 +31,7 @@ class cSearchButton
GuiSearchBar::GuiSearchBar(const wchar_t *SearchChars) :
inSide(0), text((char *) NULL, 22, ( GXColor )
{ 0, 0, 0, 255}), buttons(0), keyImageData(keyboard_key_png, keyboard_key_png_size), keyOverImageData(keyboard_key_over_png, keyboard_key_over_png_size), sndOver(
button_over_pcm, button_over_pcm_size, Settings.sfxvolume), sndClick(button_click_pcm,
button_click_pcm_size, Settings.sfxvolume)
{ 0, 0, 0, 255}), buttons(0), keyImageData(keyboard_key_png, keyboard_key_png_size), keyOverImageData(keyboard_key_over_png, keyboard_key_over_png_size)
{
trig.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
@ -57,7 +55,7 @@ GuiSearchBar::GuiSearchBar(const wchar_t *SearchChars) :
if (x == 0) y++;
charstr[0] = SearchChars[i];
buttons[i] = new cSearchButton(charstr, &keyImageData, &keyOverImageData, x_start + x * 42, y_start - 42 + y
* 42, &trig, &sndOver, &sndClick);
* 42, &trig, btnSoundOver, btnSoundClick);
this->Append(&(buttons[i]->button));
}
height = 10 + 42 + y * 42 + 10;
@ -73,16 +71,14 @@ GuiSearchBar::GuiSearchBar(const wchar_t *SearchChars) :
BacspaceBtnImg_Over = new GuiImage(imgBacspaceBtn);
BacspaceBtnImg = new GuiImage(BacspaceBtnImg_Over);
BacspaceBtnImg->SetGrayscale();
BacspaceBtn = new GuiButton(BacspaceBtnImg, BacspaceBtnImg_Over, ALIGN_RIGHT, ALIGN_TOP, -52, 10, &trig, &sndOver,
&sndClick, 1);
BacspaceBtn = new GuiButton(BacspaceBtnImg, BacspaceBtnImg_Over, ALIGN_RIGHT, ALIGN_TOP, -52, 10, &trig, btnSoundOver, btnSoundClick, 1);
this->Append(BacspaceBtn);
imgClearBtn = Resources::GetImageData("keyboard_clear_over.png");
ClearBtnImg_Over = new GuiImage(imgClearBtn);
ClearBtnImg = new GuiImage(ClearBtnImg_Over);
ClearBtnImg->SetGrayscale();
ClearBtn = new GuiButton(ClearBtnImg, ClearBtnImg_Over, ALIGN_RIGHT, ALIGN_TOP, -10, 10, &trig, &sndOver,
&sndClick, 1);
ClearBtn = new GuiButton(ClearBtnImg, ClearBtnImg_Over, ALIGN_RIGHT, ALIGN_TOP, -10, 10, &trig, btnSoundOver, btnSoundClick, 1);
this->Append(ClearBtn);
// SetPosition(100,100);

View File

@ -30,7 +30,5 @@ class GuiSearchBar: public GuiWindow
GuiImageData keyImageData;
GuiImageData keyOverImageData;
GuiTrigger trig;
GuiSound sndOver;
GuiSound sndClick;
};

View File

@ -1,446 +0,0 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_sound.cpp
*
* decoder modification by ardi 2009
*
* GUI class definitions
***************************************************************************/
#include "gui.h"
#include <unistd.h>
#include "gecko.h"
#include "gui_sound_decoder.h"
#define BUFFER_SIZE 8192
/***************************************************************
*
* D E C O D E R L I S T
*
*
***************************************************************/
GuiSoundDecoder::DecoderListEntry *GuiSoundDecoder::DecoderList = NULL;
GuiSoundDecoder::DecoderListEntry &GuiSoundDecoder::RegisterDecoder(DecoderListEntry &Decoder,
GuiSoundDecoderCreate fnc)
{
if (Decoder.fnc != fnc)
{
Decoder.fnc = fnc;
Decoder.next = DecoderList;
DecoderList = &Decoder;
}
return Decoder;
}
GuiSoundDecoder *GuiSoundDecoder::GetDecoder(const u8 * snd, u32 len, bool snd_is_allocated)
{
for (DecoderListEntry *de = DecoderList; de; de = de->next)
{
GuiSoundDecoder *d = NULL;
try
{
d = de->fnc(snd, len, snd_is_allocated);
}
catch (const char *error)
{
gprintf("%s", error);
}
catch (...)
{
}
if (d) return d;
}
return NULL;
}
/***************************************************************
*
* D E C O D E R T H R E A D
*
*
***************************************************************/
static GuiSound *GuiSoundPlayer[16] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL };
static lwp_t GuiSoundDecoderThreadHandle = LWP_THREAD_NULL;
static bool GuiSoundDecoderThreadRunning = false;
static bool GuiSoundDecoderDataRquested = false;
void *GuiSoundDecoderThread(void *args)
{
GuiSoundDecoderThreadRunning = true;
do
{
if (GuiSoundDecoderDataRquested)
{
GuiSoundDecoderDataRquested = false;
GuiSound **players = GuiSoundPlayer;
for (int i = 0; i < 16; ++i, ++players)
{
GuiSound *player = *players;
if (player) player->DecoderCallback();
}
}
if (!GuiSoundDecoderDataRquested) usleep(50);
} while (GuiSoundDecoderThreadRunning);
return 0;
}
/***************************************************************
*
* A S N D C A L L B A C K
*
*
***************************************************************/
void GuiSoundPlayerCallback(s32 Voice)
{
if (Voice >= 0 && Voice < 16 && GuiSoundPlayer[Voice])
{
GuiSoundPlayer[Voice]->PlayerCallback();
GuiSoundDecoderDataRquested = true;
}
}
/***************************************************************
*
* R A W - D E C O D E R
* Decoder for Raw-PCM-Datas (16bit Stereo 48kHz)
*
***************************************************************/
class GuiSoundDecoderRAW: public GuiSoundDecoder
{
protected:
GuiSoundDecoderRAW(const u8 * snd, u32 len, bool snd_is_allocated)
{
pcm_start = snd;
is_allocated = snd_is_allocated;
pcm_end = pcm_start + len;
pos = pcm_start;
is_running = false;
}
public:
~GuiSoundDecoderRAW()
{
while (is_running)
usleep(50);
if (is_allocated) delete[] pcm_start;
}
static GuiSoundDecoder *Create(const u8 * snd, u32 len, bool snd_is_allocated)
{
try
{
return new GuiSoundDecoderRAW(snd, len, snd_is_allocated);
}
catch (...)
{
}
return NULL;
}
s32 GetFormat()
{
return VOICE_STEREO_16BIT;
}
s32 GetSampleRate()
{
return 48000;
}
/* Read reads data from stream to buffer
return: >0 = readed bytes;
0 = EOF;
<0 = Error;
*/
int Read(u8 * buffer, int buffer_size)
{
if (pos >= pcm_end) return 0; // EOF
is_running = true;
if (pos + buffer_size > pcm_end) buffer_size = pcm_end - pos;
memcpy(buffer, pos, buffer_size);
pos += buffer_size;
is_running = false;
return buffer_size;
}
int Rewind()
{
pos = pcm_start;
return 0;
}
private:
const u8 *pcm_start;
const u8 *pcm_end;
bool is_allocated;
const u8 *pos;
bool is_running;
};
/***************************************************************
*
* G u i S o u n d
*
*
***************************************************************/
#define GuiSoundBufferReady 0x01
#define GuiSoundBufferEOF 0x02
#define GuiSoundFinish 0x04
static int GuiSoundCount = 0;
/**
* Constructor for the GuiSound class.
*/
GuiSound::GuiSound(const u8 *s, int l, int v/*=100*/, bool r/*=true*/, bool a/*=false*/)
{
if (GuiSoundCount++ == 0 || GuiSoundDecoderThreadHandle == LWP_THREAD_NULL)
{
LWP_CreateThread(&GuiSoundDecoderThreadHandle, GuiSoundDecoderThread, NULL, NULL, 32768, 80);
}
voice = -1;
play_buffer[0] = (u8*) memalign(32, BUFFER_SIZE * 3); // tripple-buffer first is played
play_buffer[1] = play_buffer[0] + BUFFER_SIZE; // second is waiting
play_buffer[2] = play_buffer[1] + BUFFER_SIZE; // third is decoding
buffer_nr = 0; // current playbuffer
buffer_pos = 0; // current idx to write in buffer
buffer_ready = false;
buffer_eof = false;
loop = false; // play looped
volume = v; // volume
decoder = NULL;
if (play_buffer[0]) // playbuffer ok
Load(s, l, r, a);
}
bool GuiSound::Load(const u8 *s, int l, bool r/*=false*/, bool a/*=false*/)
{
Stop();
if (!play_buffer[0]) return false;
GuiSoundDecoder *newDecoder = GuiSoundDecoder::GetDecoder(s, l, a);
if (!newDecoder && r) newDecoder = GuiSoundDecoderRAW::Create(s, l, a);
if (newDecoder)
{
delete decoder;
decoder = newDecoder;
return true;
}
else if (a) delete[] s;
return false;
}
GuiSound::GuiSound(const char *p, int v/*=100*/)
{
if (GuiSoundCount++ == 0 || GuiSoundDecoderThreadHandle == LWP_THREAD_NULL)
{
LWP_CreateThread(&GuiSoundDecoderThreadHandle, GuiSoundDecoderThread, NULL, NULL, 32 * 1024, 80);
}
voice = -1;
play_buffer[0] = (u8*) memalign(32, BUFFER_SIZE * 3); // tripple-buffer first is played
play_buffer[1] = play_buffer[0] + BUFFER_SIZE; // second is waiting
play_buffer[2] = play_buffer[1] + BUFFER_SIZE; // third is decoding
buffer_nr = 0; // current playbuffer
buffer_pos = 0; // current idx to write in buffer
buffer_ready = false;
buffer_eof = false;
loop = false; // play looped
volume = v; // volume
decoder = NULL;
if (play_buffer[0]) // playbuffer ok
Load(p);
}
bool GuiSound::Load(const char *p)
{
Stop(); // stop playing
if (!play_buffer[0]) return false;
bool ret = false;
voice = -2; // -2 marks loading from file
u32 filesize = 0;
u8 *buffer = NULL;
size_t result;
FILE * pFile = fopen(p, "rb");
if (pFile)
{
// get file size:
fseek(pFile, 0, SEEK_END);
filesize = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
// allocate memory to contain the whole file:
buffer = new (std::nothrow) u8[filesize];
if (buffer)
{
// copy the file into the buffer:
result = fread(buffer, 1, filesize, pFile);
if (result == filesize)
ret = Load(buffer, filesize, false, true);
else delete[] buffer;
}
fclose(pFile);
}
return ret;
}
/**
* Destructor for the GuiSound class.
*/
GuiSound::~GuiSound()
{
if (!loop) while (voice >= 0)
usleep(50);
Stop();
if (--GuiSoundCount == 0 && GuiSoundDecoderThreadHandle != LWP_THREAD_NULL)
{
GuiSoundDecoderThreadRunning = false;
LWP_JoinThread(GuiSoundDecoderThreadHandle, NULL);
GuiSoundDecoderThreadHandle = LWP_THREAD_NULL;
}
delete decoder;
free(play_buffer[0]);
}
void GuiSound::Play()
{
Stop(); // stop playing if it played
if (!play_buffer[0]) return;
if (!decoder) return; // no decoder or no play_buffer -> no playing
// initialize the buffer
buffer_nr = 0; // allways starts with buffer 0
buffer_pos = 0; // reset position
buffer_ready = false;
buffer_eof = false;
decoder->Rewind(); // play from begin
DecoderCallback(); // fill first buffer;
if (!buffer_ready || buffer_eof) // if first buffer not ready -> no play
return;
voice = ASND_GetFirstUnusedVoice();
if (voice >= 0)
{
s32 vol = (255 * volume) / 100;
s32 format = decoder->GetFormat();
s32 samplerate = decoder->GetSampleRate();
s32 first_pos = buffer_pos;
// switch to next buffer
buffer_nr = 1;
buffer_pos = 0;
buffer_ready = false;
buffer_eof = false;
DecoderCallback(); // fill second buffer;
GuiSoundPlayer[voice] = this; // activate Callbacks for this voice
// Play the voice
ASND_SetVoice(voice, format, samplerate, 0, play_buffer[0], first_pos, vol, vol, GuiSoundPlayerCallback);
}
}
/*
int GuiSound::PlayOggFile(char * path)
{
if(Load(path))
Play();
return 1;
}
*/
void GuiSound::Stop()
{
if (voice < 0) return;
GuiSoundPlayer[voice] = NULL; // disable Callbacks
SND_StopVoice(voice);
voice = -1;
}
void GuiSound::Pause()
{
if (voice < 0) return;
ASND_PauseVoice(voice, 1);
}
void GuiSound::Resume()
{
if (voice < 0) return;
ASND_PauseVoice(voice, 0);
}
bool GuiSound::IsPlaying()
{
return voice >= 0;
}
void GuiSound::SetVolume(int vol)
{
volume = vol;
if (voice < 0) return;
int newvol = 255 * (volume / 100.0);
ASND_ChangeVolumeVoice(voice, newvol, newvol);
}
void GuiSound::SetLoop(bool l)
{
loop = l;
}
void GuiSound::DecoderCallback()
{
if (buffer_ready || buffer_eof) // if buffer ready or EOF -> nothing
return;
bool error = false;
while (buffer_pos < BUFFER_SIZE)
{
int ret = decoder->Read(&play_buffer[buffer_nr][buffer_pos], BUFFER_SIZE - buffer_pos);
if (ret > 0)
buffer_pos += ret; // ok -> fill the buffer more
else if (ret == 0) // EOF from decoder
{
if (loop)
decoder->Rewind(); // if loop -> rewind and fill the buffer more
else if (buffer_pos)
break; // has data in buffer -> play the buffer
else buffer_eof = true; // no data in buffer -> return EOF
return;
}
else if (ret < 0) // an ERROR
{
if (buffer_pos)
break; // has data in buffer -> play the buffer
else if (loop)
{
if (!error) // if no prev error
{
decoder->Rewind(); // if loop -> rewind
error = true; // set error-state
continue; // and fill the buffer more
}
buffer_eof = true; // has prev error -> error in first block -> return EOF
return;
}
else
{
buffer_eof = true; // no loop -> return EOF
return;
}
}
error = false; // clear error-state
}
buffer_ready = true;
}
void GuiSound::PlayerCallback()
{
if (buffer_eof) // if EOF
{
if (ASND_TestPointer(voice, play_buffer[(buffer_nr + 2) % 3]) == 0) // test prev. Buffer
Stop();
}
else if (buffer_ready) // if buffer ready
{
if (ASND_AddVoice(voice, play_buffer[buffer_nr], buffer_pos) == SND_OK) // add buffer
{
// next buffer
buffer_nr = (buffer_nr + 1) % 3;
buffer_pos = 0;
buffer_ready = false;
buffer_eof = false;
}
}
}

View File

@ -1,114 +0,0 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_sound_decoder.h
*
* by ardi 2009
*
* GUI class definitions
***************************************************************************/
#ifndef GUI_SOUND_DECODER_H
#define GUI_SOUND_DECODER_H
#include <gccore.h>
#define REGISTER_GUI_SOUND_DECODER(decoder) GuiSoundDecoder::DecoderListEntry decoder##_l = GuiSoundDecoder::RegisterDecoder(decoder##_l, decoder::Create)
class GuiSoundDecoder;
typedef GuiSoundDecoder *(*GuiSoundDecoderCreate)(const u8 * snd, u32 len, bool snd_is_allocated);
class GuiSoundDecoder
{
protected:
GuiSoundDecoder()
{
}
; // Constructors must protected so it can create only with Init(...);
public:
virtual ~GuiSoundDecoder()
{
}
;
// begin API
// ---------
// each Decoder must have an own static Create(...) fnc
// static GuiSoundDecoder *Create(const u8 * snd, u32 len, bool snd_is_allocated);
virtual s32 GetFormat() = 0;
virtual s32 GetSampleRate() = 0;
/* Read reads data from stream to buffer
return: >0 = readed bytes;
0 = EOF;
<0 = Error;
*/
virtual int Read(u8 * buffer, int buffer_size) = 0;
// set the stream to the start
virtual int Rewind() = 0;
// -------
// end API
struct DecoderListEntry
{
GuiSoundDecoderCreate fnc;
DecoderListEntry *next;
};
static DecoderListEntry &RegisterDecoder(DecoderListEntry &Decoder, GuiSoundDecoderCreate fnc);
static GuiSoundDecoder *GetDecoder(const u8 * snd, u32 len, bool snd_is_allocated);
private:
static DecoderListEntry *DecoderList;
GuiSoundDecoder(GuiSoundDecoder&); // no copy
};
#define BIG_ENDIAN_HOST 1 // Wii PPC is a Big-Endian-Host
#if BIG_ENDIAN_HOST
inline uint16_t be16(const uint8_t *p8)
{
return *((uint16_t*) p8);
}
inline uint32_t be32(const uint8_t *p8)
{
return *((uint32_t*) p8);
}
inline uint16_t le16(const uint8_t *p8)
{
uint16_t ret = p8[1] << 8 | p8[0];
return ret;
}
inline uint32_t le32(const uint8_t *p8)
{
uint32_t ret = p8[3] << 24 | p8[2] << 16 | p8[1] << 8 | p8[0];
return ret;
}
#elif LITTLE_ENDIAN_HOST
inline uint16_t be16( const uint8_t *p8 )
{
uint16_t ret = p8[0] << 8 | p8[1];
return ret;
}
inline uint32_t be32( const uint8_t *p8 )
{
uint32_t ret = p8[0] << 24 | p8[1] << 16 | p8[2] << 8 | p8[3];
return ret;
}
inline uint16_t le16( const uint8_t *p8 )
{
return *( ( uint16_t* )p8 );
}
inline uint32_t le32( const uint8_t *p8 )
{
return *( ( uint32_t* )p8 );
}
#else
#error "BIG_ENDIAN_HOST or LITTLE_ENDIAN_HOST not setted"
#endif /* XXX_ENDIAN_HOST */
#define be16inc(p8) (p8+=2, be16(p8-2))
#define le16inc(p8) (p8+=2, le16(p8-2))
#define be32inc(p8) (p8+=4, be32(p8-4))
#define le32inc(p8) (p8+=4, le32(p8-4))
#endif /* GUI_SOUND_DECODER_H */

View File

@ -1,158 +0,0 @@
/****************************************************************************
* libwiigui
*
* ardi 2009
*
* gui_sound_plugin_aif.cpp
*
* GUI class definitions
***************************************************************************/
#include <limits.h>
#include <asndlib.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
#include "gui_sound_decoder.h"
// ------
// Copyright (C) 1988-1991 Apple Computer, Inc.
#ifndef HUGE_VAL
# define HUGE_VAL HUGE
#endif
# define UnsignedToFloat(u) (((double)((long)(u - 2147483647L - 1))) + 2147483648.0)
static double ConvertFromIeeeExtended(const u8* bytes)
{
double f;
int expon;
u32 hiMant, loMant;
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
hiMant = ((unsigned long) (bytes[2] & 0xFF) << 24) | ((unsigned long) (bytes[3] & 0xFF) << 16)
| ((unsigned long) (bytes[4] & 0xFF) << 8) | ((unsigned long) (bytes[5] & 0xFF));
loMant = ((unsigned long) (bytes[6] & 0xFF) << 24) | ((unsigned long) (bytes[7] & 0xFF) << 16)
| ((unsigned long) (bytes[8] & 0xFF) << 8) | ((unsigned long) (bytes[9] & 0xFF));
if (expon == 0 && hiMant == 0 && loMant == 0)
f = 0;
else
{
if (expon == 0x7FFF)
f = HUGE_VAL;
else
{
expon -= 16383;
f = ldexp(UnsignedToFloat( hiMant ), expon -= 31);
f += ldexp(UnsignedToFloat( loMant ), expon -= 32);
}
}
if (bytes[0] & 0x80)
return -f;
else return f;
}
// ------
class GuiSoundDecoderAIFF: public GuiSoundDecoder
{
protected:
GuiSoundDecoderAIFF(const u8 * snd, u32 len, bool snd_is_allocated)
{
sound = snd;
length = len;
is_allocated = snd_is_allocated;
is_running = false;
const u8 *in_ptr = sound;
if (be32inc( in_ptr ) != 0x464F524D /*'FORM'*/) throw("No FORM chunk");
if (be32inc( in_ptr ) + 8 != len) throw("wrong Size");
if (be32inc( in_ptr ) != 0x41494646 /*'AIFF'*/) throw("No AIFF chunk");
while (in_ptr + 8 < sound + len)
{
u32 chunk_id = be32inc( in_ptr );
u32 chunk_size = be32inc( in_ptr );
const u8 *chunk_start = in_ptr;
switch (chunk_id)
{
case 0x434F4D4D /*'COMM'*/:
channelCount = be16inc( in_ptr );
in_ptr += 4; // skip numSampleFrames
bytePerSample = (be16inc( in_ptr ) + 7) / 8;
if (bytePerSample < 1 && bytePerSample > 2) throw("wrong bits per Sample");
sampleRate = ConvertFromIeeeExtended(in_ptr);
break;
case 0x53534E44 /*'SSND'*/:
pcm_start = in_ptr + 8;
pcm_end = chunk_start + chunk_size;
break;
}
in_ptr = chunk_start + chunk_size;
}
currentPos = pcm_start;
}
public:
~GuiSoundDecoderAIFF()
{
while (is_running)
usleep(50);
if (is_allocated) delete[] sound;
}
static GuiSoundDecoder *Create(const u8 * snd, u32 len, bool snd_is_allocated)
{
if (snd && len > 12 && snd[0] == 'F' && snd[1] == 'O' && snd[2] == 'R' && snd[3] == 'M' && snd[8] == 'A'
&& snd[9] == 'I' && snd[10] == 'F' && snd[11] == 'F') return new GuiSoundDecoderAIFF(snd, len,
snd_is_allocated);
return NULL;
}
s32 GetFormat()
{
if (bytePerSample == 2)
return channelCount == 2 ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT;
else return channelCount == 2 ? VOICE_STEREO_8BIT : VOICE_MONO_8BIT;
}
s32 GetSampleRate()
{
return sampleRate;
}
/* Read reads data from stream to buffer
return: >0 = readed bytes;
0 = EOF;
<0 = Error;
*/
int Read(u8 * buffer, int buffer_size)
{
if (currentPos >= pcm_end) return 0; // EOF
is_running = true;
if (currentPos + buffer_size > pcm_end) buffer_size = pcm_end - currentPos;
memcpy(buffer, currentPos, buffer_size);
currentPos += buffer_size;
is_running = false;
return buffer_size;
}
int Rewind()
{
while (is_running)
usleep(50);
currentPos = pcm_start;
return 0;
}
private:
const u8 *sound;
u32 length;
bool is_allocated;
bool is_running;
u32 sampleRate;
u16 channelCount;
u16 bytePerSample;
const u8 *pcm_start;
const u8 *pcm_end;
const u8 *currentPos;
};
REGISTER_GUI_SOUND_DECODER( GuiSoundDecoderAIFF );

View File

@ -1,257 +0,0 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_sound_plugin_bns.cpp
*
* by ardi 2009
*
* Decoder for Wii bns-sound
*
* GUI class definitions
***************************************************************************/
#include <asndlib.h>
#include <unistd.h>
#include "gui_sound_decoder.h"
#define BIG_ENDIAN_HOST 1
class chanel_t
{
public:
void Reset()
{
currentPos = startPos;
hist1 = hist2 = 0;
}
int DecodeNextBlock()
{
int Offset = 0;
if (currentPos == loopStart)
{
loop_hist1 = hist1;
loop_hist2 = hist2;
}
if (loop && currentPos >= endPos)
{
currentPos = loopStart;
hist1 = loop_hist1;
hist2 = loop_hist2;
Offset = loopOffset;
}
if (currentPos + 8 <= endPos)
{
u16 index = (*currentPos >> 4) & 0x07;
s32 scale = 1 << (*currentPos++ & 0x0F);
for (int i = 0; i < 14; i += 2)
{
nibbles[i] = ((s8) *currentPos) >> 4;
nibbles[i + 1] = ((s8) ((*currentPos++) << 4)) >> 4;
}
for (int i = 0; i < 14; ++i)
{
s32 sample = (scale * nibbles[i]) << 11;
sample += coEfficients[index * 2] * hist1;
sample += coEfficients[index * 2 + 1] * hist2;
sample += 1024;
sample = sample >> 11;
if (sample > 32767)
sample = 32767;
else if (sample < -32768) sample = -32768;
pcm[i] = sample;
hist2 = hist1;
hist1 = sample;
}
return Offset;
}
return -1;
}
const u8* startPos;
const u8* endPos;
const u8* currentPos;
s16 coEfficients[16];
s16 nibbles[14];
s16 pcm[14];
s16 hist1;
s16 hist2;
bool loop;
const u8* loopStart;
u16 loopOffset;
s16 loop_hist1;
s16 loop_hist2;
};
class GuiSoundDecoderBNS: public GuiSoundDecoder
{
protected:
GuiSoundDecoderBNS(const u8 * snd, u32 len, bool snd_is_allocated)
{
sound = snd;
is_running = false;
is_allocated = snd_is_allocated;
const u8 *in_ptr = sound;
/////////////////
// READ HEADER //
/////////////////
if (be32inc( in_ptr ) != 0x424E5320 /*'BNS '*/) throw("Not a BNS");
in_ptr += 4; // skip 4 byte
u32 bnssize = be32inc( in_ptr );
if (bnssize != len) throw("Wrong size");
in_ptr += 4; // skip unknown1
const u8* infoStart = sound + be32inc( in_ptr );
in_ptr += 4; // skip const u8* infoEnd = infoStart + be32inc(in_ptr);
channel[0].startPos = sound + be32inc( in_ptr ) + 8;
channel[0].endPos = channel[0].startPos + be32inc( in_ptr ) - 8;
///////////////
// READ INFO //
///////////////
in_ptr = infoStart + 8; // skip 'INFO' and Infosize
in_ptr++; // skip u8 codeType = *in_ptr++;
channel[0].loop = channel[1].loop = *in_ptr++; // u8 loopFlag;
channelCount = *in_ptr++;
in_ptr++; // skip unknown byte
sampleRate = be16inc( in_ptr );
in_ptr += 2; // skip unknown word
u32 loopStart = be32inc( in_ptr );
channel[0].loopStart = channel[0].startPos + ((loopStart / 14) * 8);//LoopPos to BlockStart
channel[1].loopStart = channel[1].startPos + ((loopStart / 14) * 8);
channel[0].loopOffset = channel[1].loopOffset = loopStart % 14;
in_ptr += 4; // skip u32 SampleCount = be32inc(in_ptr);
in_ptr += 24; // skip unknown Bytes
if (channelCount == 2)
{
in_ptr += 4; // skip unknown long
u32 ChannelSplit = be32inc( in_ptr );
in_ptr += 8; // skip 2x unknown long
channel[1].endPos = channel[0].endPos;
channel[0].endPos = channel[1].startPos = channel[0].startPos + ChannelSplit;
channel[1].loopStart = channel[1].startPos + (channel[0].loopStart - channel[0].startPos);
}
for (int a = 0; a < 16; a++)
{
channel[0].coEfficients[a] = (s16) be16inc( in_ptr );
}
if (channelCount == 2)
{
in_ptr += 16; // skip 16 byte
for (int a = 0; a < 16; a++)
{
channel[1].coEfficients[a] = (s16) be16inc( in_ptr );
}
}
channel[0].Reset();
channel[1].Reset();
currentBlockPos = 14;
}
public:
~GuiSoundDecoderBNS()
{
while (is_running)
usleep(50);
if (is_allocated) delete[] sound;
}
static GuiSoundDecoder *Create(const u8 * snd, u32 len, bool snd_is_allocated)
{
if (snd && len > 4 && snd[0] == 'B' && snd[1] == 'N' && snd[2] == 'S' && snd[3] == ' ') return new GuiSoundDecoderBNS(
snd, len, snd_is_allocated);
return NULL;
}
s32 GetFormat()
{
return channelCount == 2 ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT;
}
s32 GetSampleRate()
{
return sampleRate;
}
/* Read reads data from stream to buffer
return: >0 = readed bytes;
0 = EOF;
<0 = Error;
*/
int Read(u8 * buffer, int buffer_size)
{
is_running = true;
u8 *write_pos = buffer;
u8 *write_end = buffer + buffer_size;
for (;;)
{
if (currentBlockPos >= 14)
{
int Offset = channel[0].DecodeNextBlock();
if (Offset < 0 || (channelCount == 2 && channel[1].DecodeNextBlock() < 0))
{
is_running = false;
return write_pos - buffer;
}
currentBlockPos = Offset;
}
for (; currentBlockPos < 14; ++currentBlockPos)
{
if (write_pos >= write_end)
{
is_running = false;
return write_pos - buffer;
}
*((s16*) write_pos) = channel[0].pcm[currentBlockPos];
write_pos += 2;
if (channelCount == 2) // stereo
{
*((s16*) write_pos) = channel[1].pcm[currentBlockPos];
write_pos += 2;
}
}
}
is_running = false;
return 0;
}
int Rewind()
{
channel[0].Reset();
channel[1].Reset();
currentBlockPos = 14;
return 0;
}
private:
const u8 *sound;
bool is_allocated;
bool is_running;
chanel_t channel[2];
u16 currentBlockPos;
u16 channelCount;
u32 sampleRate;
// u16 loopOffset;
// u16 bytePerSample;
// const u8 *soundDataStart;
// const u8 *soundDataEnd;
// u32 soundDataLen;
};
REGISTER_GUI_SOUND_DECODER( GuiSoundDecoderBNS );

View File

@ -1,213 +0,0 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_sound_plugin_mpg.cpp
*
* by ardi 2009
*
* Decoder for MPEG-Audio Mpeg-1/-2 Layer I,II and III with libmad
*
* GUI class definitions
***************************************************************************/
#include <unistd.h>
#include <limits.h>
#include <asndlib.h>
#include <mad.h>
#include <string.h>
#include <new>
#include "gui_sound_decoder.h"
static inline s16 FixedToShort(mad_fixed_t Fixed)
{
/* Clipping */
if (Fixed >= MAD_F_ONE) return (SHRT_MAX);
if (Fixed <= -MAD_F_ONE) return (-SHRT_MAX);
Fixed = Fixed >> (MAD_F_FRACBITS - 15);
return ((s16) Fixed);
}
#define ADMA_BUFFERSIZE (8192)
#define DATABUFFER_SIZE (32768)
// http://www.fr-an.de/fragen/v06/02_01.htm
class GuiSoundDecoderMPG: public GuiSoundDecoder
{
protected:
GuiSoundDecoderMPG(const u8 * snd, u32 len, bool snd_is_allocated)
{
sound = snd;
length = len;
is_allocated = snd_is_allocated;
// Init mad-structures
mad_stream_init(&madStream);
mad_stream_buffer(&madStream, sound, length);
mad_frame_init(&madFrame);
mad_synth_init(&madSynth);
madSynthPcmPos = 0;
mad_timer_reset( &madTimer );
guardBuffer = NULL;
is_running = false;
// decode first Frame
if (DecodeFirstFrame())
{
mad_synth_finish( &madSynth );
mad_frame_finish(&madFrame);
mad_stream_finish(&madStream);
throw("Stream Error");
}
}
public:
~GuiSoundDecoderMPG()
{
while (is_running)
usleep(50);
mad_synth_finish( &madSynth );
mad_frame_finish(&madFrame);
mad_stream_finish(&madStream);
delete[] guardBuffer;
if (is_allocated) delete[] sound;
}
static GuiSoundDecoder *Create(const u8 * snd, u32 len, bool snd_is_allocated)
{
struct mad_stream madStream;
struct mad_header madHeader;
mad_stream_init(&madStream);
mad_stream_buffer(&madStream, snd, len);
mad_header_init(&madHeader);
s32 ret = mad_header_decode(&madHeader, &madStream);
if (ret == 0 || madStream.error == MAD_ERROR_LOSTSYNC) // LOSTSYNC in first call is ok
{
int i;
for (i = 0; i < 4 && mad_header_decode(&madHeader, &madStream) == 0; i++)
;
if (i == 4)
{
mad_header_finish( &madHeader );
mad_stream_finish(&madStream);
return new GuiSoundDecoderMPG(snd, len, snd_is_allocated);
}
} mad_header_finish( &madHeader );
mad_stream_finish(&madStream);
return NULL;
}
s32 GetFormat()
{
return MAD_NCHANNELS( &madFrame.header ) == 2 ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT;
}
s32 GetSampleRate()
{
return madFrame.header.samplerate;
}
/* Read reads data from stream to buffer
return: >0 = readed bytes;
0 = EOF;
<0 = Error;
*/
int Read(u8 * buffer, int buffer_size)
{
is_running = true;
if (MAD_NCHANNELS( &madFrame.header ) == 2) // stereo
buffer_size &= ~0x0003; // make size to a kind of 4
else buffer_size &= ~0x0001; // make size to a kind of 2
u8 *write_pos = buffer;
u8 *write_end = buffer + buffer_size;
for (;;)
{
for (; madSynthPcmPos < madSynth.pcm.length; ++madSynthPcmPos)
{
if (write_pos >= write_end)
{
is_running = false;
return write_pos - buffer;
}
*((s16*) write_pos) = FixedToShort(madSynth.pcm.samples[0][madSynthPcmPos]);
write_pos += 2;
if (MAD_NCHANNELS( &madFrame.header ) == 2) // stereo
{
*((s16*) write_pos) = FixedToShort(madSynth.pcm.samples[1][madSynthPcmPos]);
write_pos += 2;
}
}
madStream.error = MAD_ERROR_NONE;
if (mad_frame_decode(&madFrame, &madStream))
{
if (MAD_RECOVERABLE( madStream.error ))
{
if (madStream.error != MAD_ERROR_LOSTSYNC || !guardBuffer) continue;
}
else if (madStream.error == MAD_ERROR_BUFLEN)
{
if (!guardBuffer)
{
u32 guardLen = (madStream.bufend - madStream.next_frame);
guardBuffer = new (std::nothrow) u8[guardLen + MAD_BUFFER_GUARD];
if (guardBuffer)
{
memcpy(guardBuffer, madStream.next_frame, guardLen);
memset(guardBuffer + guardLen, 0, MAD_BUFFER_GUARD);
mad_stream_buffer(&madStream, guardBuffer, guardLen + MAD_BUFFER_GUARD);
continue;
}
}
}
break;
}
mad_timer_add(&madTimer, madFrame.header.duration);
mad_synth_frame(&madSynth, &madFrame);
madSynthPcmPos = 0;
}
is_running = false;
return write_pos - buffer;
}
int Rewind()
{
while (is_running)
usleep(50);
delete[] guardBuffer;
guardBuffer = NULL;
mad_stream_buffer(&madStream, sound, length);
mad_synth_finish( &madSynth );
mad_synth_init(&madSynth);
madSynthPcmPos = 0;
mad_timer_reset( &madTimer );
// decode first Frame
return DecodeFirstFrame();
}
private:
int DecodeFirstFrame()
{
for (;;)
{
madStream.error = MAD_ERROR_NONE;
if (mad_frame_decode(&madFrame, &madStream))
{
if (MAD_RECOVERABLE( madStream.error ))
continue;
else return -1;
}
mad_timer_add(&madTimer, madFrame.header.duration);
mad_synth_frame(&madSynth, &madFrame);
return 0;
}
}
const u8 *sound;
u32 length;
bool is_allocated;
struct mad_stream madStream;
struct mad_frame madFrame;
struct mad_synth madSynth;
u16 madSynthPcmPos;
mad_timer_t madTimer;
u8 *guardBuffer;
bool is_running;
};
REGISTER_GUI_SOUND_DECODER( GuiSoundDecoderMPG );

View File

@ -1,285 +0,0 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_sound_plugin_ogg.cpp
*
* by ardi 2009
*
* Decoder for ogg-vorbis with libtremor
*
* GUI class definitions
***************************************************************************/
#include <unistd.h>
#include <asndlib.h>
#include <tremor/ivorbiscodec.h>
#include <tremor/ivorbisfile.h>
#include <string.h>
#include "gui_sound_decoder.h"
/* functions to read the Ogg file from memory */
static struct
{
char *mem;
int size;
int pos;
} file[4];
static int f_read(void * punt, int bytes, int blocks, int *f)
{
int b;
int c = 0;
int d;
if (bytes * blocks <= 0) return 0;
blocks *= bytes;
while (blocks > 0)
{
b = blocks;
if (b > 4096) b = 4096;
d = (*f) - 0x666;
if ((unsigned) (d) <= (0x669 - 0x666))
{
if (file[d].size == 0) return -1;
if ((file[d].pos + b) > file[d].size) b = file[d].size - file[d].pos;
if (b > 0)
{
memcpy(punt, file[d].mem + file[d].pos, b);
file[d].pos += b;
}
}
else b = read(*f, ((char *) punt) + c, b);
if (b <= 0)
{
return c / bytes;
}
c += b;
blocks -= b;
}
return c / bytes;
}
static int f_seek(int *f, ogg_int64_t offset, int mode)
{
if (f == NULL) return (-1);
int k;
mode &= 3;
int d = (*f) - 0x666;
if ((unsigned) (d) <= (0x669 - 0x666))
{
k = 0;
if (file[d].size == 0) return -1;
if (mode == 0)
{
if ((offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else file[d].pos = offset;
}
else if (mode == 1)
{
if ((file[d].pos + offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((file[d].pos + offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else file[d].pos += offset;
}
else if (mode == 2)
{
if ((file[d].size + offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((file[d].size + offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else file[d].pos = file[d].size + offset;
}
}
else k = lseek(*f, (int) offset, mode);
if (k < 0)
k = -1;
else k = 0;
return k;
}
static int f_close(int *f)
{
int d = (*f) - 0x666;
if ((unsigned) (d) <= (0x669 - 0x666))
{
file[d].size = 0;
file[d].pos = 0;
if (file[d].mem)
{
file[d].mem = (char *) 0;
}
return 0;
}
else return close(*f);
return 0;
}
static long f_tell(int *f)
{
int k;
int d = (*f) - 0x666;
if ((unsigned) (d) <= (0x669 - 0x666))
{
k = file[d].pos;
}
else k = lseek(*f, 0, 1);
return (long) k;
}
static int mem_open(char * ogg, int size)
{
static int one = 1;
int n;
if (one)
{
one = 0;
file[0].size = 0;
file[1].size = 0;
file[2].size = 0;
file[3].size = 0;
file[0].mem = ogg;
file[0].size = size;
file[0].pos = 0;
return (0x666);
}
for (n = 0; n < 4; n++)
{
if (file[n].size == 0)
{
file[n].mem = ogg;
file[n].size = size;
file[n].pos = 0;
return (0x666 + n);
}
}
return -1;
}
static int mem_close(int fd)
{
if ((unsigned) ((fd) - 0x666) <= (0x669 - 0x666)) // it is a memory file descriptor?
{
fd -= 0x666;
file[fd].size = 0;
return 0;
}
else return f_close(&fd);
}
static ov_callbacks callbacks = { (size_t(*)(void *, size_t, size_t, void *)) f_read,
(int(*)(void *, ogg_int64_t, int)) f_seek, (int(*)(void *)) f_close, (long(*)(void *)) f_tell };
class GuiSoundDecoderOGG: public GuiSoundDecoder
{
protected:
GuiSoundDecoderOGG(const u8 * snd, u32 len, bool snd_is_allocated)
{
sound = snd;
is_allocated = snd_is_allocated;
ogg_fd = mem_open((char *) snd, len);
if (ogg_fd < 0) throw("mem open failed");
if (ov_open_callbacks((void*) &ogg_fd, &ogg_file, NULL, 0, callbacks) < 0)
{
mem_close(ogg_fd);
throw("ogg open failed");
}
ogg_info = ov_info(&ogg_file, -1);
bitstream = 0;
is_running = false;
}
public:
~GuiSoundDecoderOGG()
{
while (is_running)
usleep(50);
ov_clear(&ogg_file);
if (is_allocated) delete[] sound;
}
static GuiSoundDecoder *Create(const u8 * snd, u32 len, bool snd_is_allocated)
{
if (snd && len > 4 && snd[0] == 'O' && snd[1] == 'g' && snd[2] == 'g' && snd[3] == 'S') return new GuiSoundDecoderOGG(
snd, len, snd_is_allocated);
return NULL;
}
s32 GetFormat()
{
return ogg_info->channels == 2 ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT;
}
s32 GetSampleRate()
{
return ogg_info->rate;
}
/* Read reads data from stream to buffer
return: >0 = readed bytes;
0 = EOF;
<0 = Error;
*/
int Read(u8 * buffer, int buffer_size)
{
is_running = true;
int ret = ov_read(&ogg_file, (char *) buffer, buffer_size, &bitstream);
if (ret < 0)
{
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
if (ret != OV_HOLE) ret = 0; // we says EOF
}
is_running = false;
return ret;
}
int Rewind()
{
return ov_time_seek(&ogg_file, 0);
}
private:
const u8 *sound;
bool is_allocated;
int ogg_fd;
OggVorbis_File ogg_file;
vorbis_info *ogg_info;
int bitstream;
bool is_running;
};
REGISTER_GUI_SOUND_DECODER( GuiSoundDecoderOGG );

View File

@ -1,237 +0,0 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_sound_plugin_wav.cpp
*
* by ardi 2009
*
* Decoder for WAVE PCM
*
* GUI class definitions
***************************************************************************/
#include <asndlib.h>
#include <map>
#include <vector>
#include <unistd.h>
#include "gui_sound_decoder.h"
typedef struct
{
u32 cueID;
u32 len;
u32 loops;
} plst_t;
typedef struct
{
const u8 *start;
const u8 *end;
u32 loops;
} playlist_t;
class GuiSoundDecoderWAV: public GuiSoundDecoder
{
protected:
GuiSoundDecoderWAV(const u8 * snd, u32 len, bool snd_is_allocated)
{
sound = snd;
is_running = false;
is_allocated = snd_is_allocated;
const u8 *in_ptr = sound;
if (be32inc( in_ptr ) != 0x52494646 /*'RIFF' (WAV)*/) throw("Not a WAV");
u32 riffsize = le32inc( in_ptr );
if (riffsize > (len - 8)) throw("Wrong size");
if (be32inc( in_ptr ) != 0x57415645 /*'WAVE'*/) throw("No WAVE-Tag");
if (be32inc( in_ptr ) != 0x666D7420 /*'fmt '*/) throw("No fmt-Tag");
u32 fmtLen = le32inc( in_ptr );
if (le16inc( in_ptr ) != 1) throw("Not PCM data");
channelCount = le16inc( in_ptr );
if (channelCount < 1 || channelCount > 2) throw("only mono or stereo");
sampleRate = le32inc( in_ptr );
in_ptr += 6; // skip <bytes/second> and <block align>
bytePerSample = (le16inc( in_ptr ) + 7) / 8;
if (bytePerSample < 1 || bytePerSample > 2) throw("only 1-16 bit/Sample");
in_ptr += fmtLen - 16;
if (be32inc( in_ptr ) != 0x64617461 /*'data'*/) throw("No data-Tag");
soundDataStart = in_ptr + 4;
soundDataEnd = soundDataStart + le32(in_ptr);
in_ptr = soundDataEnd;
std::map<u32, u32> cue;
std::vector<plst_t> plst;
if (((u32) in_ptr) & 0x0001UL) in_ptr++;
while ((in_ptr + 4) < (sound + riffsize))
{
u32 tag = be32inc( in_ptr );
switch (tag)
{
case 0x63756520 /*'cue '*/:
in_ptr += 4; // skip size
for (u32 count = le32inc( in_ptr ); count > 0; count--)
{
u32 ID = be32inc( in_ptr );
in_ptr += 4; // skip dwPosition
if (be32inc( in_ptr ) == 0x64617461 /*'data'*/)
{
in_ptr += 8; // skip chunkStart - dwBlockStart
cue[ID] = le32inc( in_ptr );
}
else in_ptr += 12; // skip chunkStart - SammpleOffset
}
break;
case 0x706C7374 /*' plst'*/:
in_ptr += 4; // skip size
for (u32 count = le32inc( in_ptr ); count > 0; count--)
plst.push_back(( plst_t )
{ le32inc( in_ptr ), le32inc( in_ptr ), le32inc( in_ptr )});
break;
default:
in_ptr -= 2;
break;
}
}
for (std::vector<plst_t>::iterator i = plst.begin(); i != plst.end(); ++i)
{
const u8 *start = soundDataStart + cue[i->cueID];
const u8 *end = soundDataStart + (i->len * bytePerSample * channelCount);
u32 loops = i->loops;
playlist.push_back(( playlist_t )
{ start, end, loops});
}
if (playlist.size() == 0)
{
playlist.push_back(( playlist_t )
{ soundDataStart, soundDataEnd, 1});
}
Rewind();
}
public:
~GuiSoundDecoderWAV()
{
while (is_running)
usleep(50);
if (is_allocated) delete[] sound;
}
static GuiSoundDecoder *Create(const u8 * snd, u32 len, bool snd_is_allocated)
{
if (snd && len > 4 && snd[0] == 'R' && snd[1] == 'I' && snd[2] == 'F' && snd[3] == 'F' && snd[8] == 'W'
&& snd[9] == 'A' && snd[10] == 'V' && snd[11] == 'E') return new GuiSoundDecoderWAV(snd, len,
snd_is_allocated);
return NULL;
}
s32 GetFormat()
{
if (bytePerSample == 2)
return channelCount == 2 ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT;
else return channelCount == 2 ? VOICE_STEREO_8BIT : VOICE_MONO_8BIT;
}
s32 GetSampleRate()
{
return sampleRate;
}
/* Read reads data from stream to buffer
return: >0 = readed bytes;
0 = EOF;
<0 = Error;
*/
int Read(u8 * buffer, int buffer_size)
{
is_running = true;
u8 *write_pos = buffer;
u8 *write_end = buffer + buffer_size;
for (;;)
{
while (currentPos < currentEnd)
{
if (write_pos >= write_end)
{
is_running = false;
return write_pos - buffer;
}
if (bytePerSample == 2)
{
*((s16*) write_pos) = le16inc( currentPos );
write_pos += 2;
if (channelCount == 2) // stereo
{
*((s16*) write_pos) = le16inc( currentPos );
write_pos += 2;
}
}
else
{
*write_pos++ = *currentPos++;
if (channelCount == 2) // stereo
*write_pos++ = *currentPos++;
}
}
if (currentLoops > 1)
{
currentLoops--;
currentPos = currentStart;
continue;
}
if (currentPlaylist != playlist.end()) currentPlaylist++;
if (currentPlaylist != playlist.end())
{
currentStart = currentPos = currentPlaylist->start;
currentEnd = currentPlaylist->end;
currentLoops = currentPlaylist->loops;
continue;
}
else
{
is_running = false;
return write_pos - buffer;
}
}
is_running = false;
return 0;
}
int Rewind()
{
currentPlaylist = playlist.begin();
currentStart = currentPos = currentPlaylist->start;
currentEnd = currentPlaylist->end;
currentLoops = currentPlaylist->loops;
return 0;
}
private:
const u8 *sound;
bool is_allocated;
bool is_running;
u16 channelCount;
u32 sampleRate;
u16 bytePerSample;
const u8 *soundDataStart;
const u8 *soundDataEnd;
std::vector<playlist_t> playlist;
std::vector<playlist_t>::iterator currentPlaylist;
const u8 *currentStart;
const u8 *currentEnd;
u32 currentLoops;
const u8 *currentPos;
};
REGISTER_GUI_SOUND_DECODER( GuiSoundDecoderWAV );

View File

@ -85,7 +85,7 @@ int main(int argc, char *argv[])
if (IosLoader::LoadAppCios() < 0)
{
printf("\n\tWARNING!\n");
printf("\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+\n\n");
printf("\tUSB Loader GX needs unstubbed cIOS 222 v4+ or 249 v9+\n\n");
printf(
"\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.\n");

View File

@ -43,7 +43,9 @@ GuiImageData * pointer[4];
GuiImage * bgImg = NULL;
GuiImageData * background = NULL;
GuiBGM * bgMusic = NULL;
GuiSound *btnClick2 = NULL;
GuiSound *btnSoundClick = NULL;
GuiSound *btnSoundClick2 = NULL;
GuiSound *btnSoundOver = NULL;
int currentMenu;
u8 mountMethod = 0;
@ -265,6 +267,10 @@ int MainMenu(int menu)
if (Settings.autonetwork)
ResumeNetworkThread();
btnSoundClick = new GuiSound(button_click_wav, button_click_wav_size, Settings.sfxvolume);
btnSoundClick2 = new GuiSound(button_click2_wav, button_click2_wav_size, Settings.sfxvolume);
btnSoundOver = new GuiSound(button_over_wav, button_over_wav_size, Settings.sfxvolume);
pointer[0] = Resources::GetImageData("player1_point.png");
pointer[1] = Resources::GetImageData("player2_point.png");
pointer[2] = Resources::GetImageData("player3_point.png");
@ -279,10 +285,15 @@ int MainMenu(int menu)
ResumeGui();
gprintf("Vor bgm\n");
bgMusic = new GuiBGM(bg_music_ogg, bg_music_ogg_size, Settings.volume);
gprintf("new bgm\n");
bgMusic->SetLoop(Settings.musicloopmode); //loop music
gprintf("SetLoop\n");
bgMusic->Load(Settings.ogg_path);
gprintf("Load\n");
bgMusic->Play();
gprintf("Nach bgm\n");
MountGamePartition();

View File

@ -11,7 +11,6 @@
#include <ogcsys.h>
#include "libwiigui/gui.h"
#include "libwiigui/gui_bgm.h"
#include "settings/CSettings.h"
#include "main.h"
@ -37,8 +36,6 @@ void ResumeGui();
void HaltGui();
GuiImageData *LoadCoverImage(struct discHdr *header, bool Prefere3D = true, bool noCover = true);
extern GuiSound *btnClick2;
extern GuiBGM *bgMusic;
extern GuiImageData *pointer[4];
extern GuiImageData *background;
extern GuiImage *bgImg;

View File

@ -161,7 +161,7 @@ int MountGamePartition(bool ShowGUI)
// open database if needed, load titles if needed
if (CheckFile(Settings.titlestxt_path))
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride == 1 ? true : false, true);
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride, true);
return ret;
}

View File

@ -96,11 +96,6 @@ int MenuDiscList()
nolist = 1;
}
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnInstall(Resources::GetFile("button_install.png"), Resources::GetFileSize("button_install.png"));
GuiImageData btnInstallOver(Resources::GetFile("button_install_over.png"), Resources::GetFileSize("button_install_over.png"));
@ -197,7 +192,7 @@ int MenuDiscList()
installBtnImgOver.SetWidescreen(Settings.widescreen);
GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, Theme.install_x, Theme.install_y,
&trigA, &btnSoundOver, btnClick2, 1, &installBtnTT, 24, -30, 0, 5);
&trigA, btnSoundOver, btnSoundClick2, 1, &installBtnTT, 24, -30, 0, 5);
GuiTooltip settingsBtnTT(tr( "Settings" ));
if (Settings.wsprompt) settingsBtnTT.SetWidescreen(Settings.widescreen);
@ -207,7 +202,7 @@ int MenuDiscList()
GuiImage settingsBtnImgOver(&btnSettingsOver);
settingsBtnImgOver.SetWidescreen(Settings.widescreen);
GuiButton settingsBtn(&settingsBtnImg, &settingsBtnImgOver, 0, 3, Theme.setting_x, Theme.setting_y, &trigA,
&btnSoundOver, btnClick2, 1, &settingsBtnTT, 65, -30, 0, 5);
btnSoundOver, btnSoundClick2, 1, &settingsBtnTT, 65, -30, 0, 5);
GuiTooltip homeBtnTT(tr( "Back to HBC or Wii Menu" ));
if (Settings.wsprompt) homeBtnTT.SetWidescreen(Settings.widescreen);
@ -216,7 +211,7 @@ int MenuDiscList()
homeBtnImg.SetWidescreen(Settings.widescreen);
GuiImage homeBtnImgOver(&btnhomeOver);
homeBtnImgOver.SetWidescreen(Settings.widescreen);
GuiButton homeBtn(&homeBtnImg, &homeBtnImgOver, 0, 3, Theme.home_x, Theme.home_y, &trigA, &btnSoundOver, btnClick2,
GuiButton homeBtn(&homeBtnImg, &homeBtnImgOver, 0, 3, Theme.home_x, Theme.home_y, &trigA, btnSoundOver, btnSoundClick2,
1, &homeBtnTT, 15, -30, 1, 5);
homeBtn.RemoveSoundClick();
homeBtn.SetTrigger(&trigHome);
@ -229,7 +224,7 @@ int MenuDiscList()
poweroffBtnImg.SetWidescreen(Settings.widescreen);
poweroffBtnImgOver.SetWidescreen(Settings.widescreen);
GuiButton poweroffBtn(&poweroffBtnImg, &poweroffBtnImgOver, 0, 3, Theme.power_x, Theme.power_y, &trigA,
&btnSoundOver, btnClick2, 1, &poweroffBtnTT, -10, -30, 1, 5);
btnSoundOver, btnSoundClick2, 1, &poweroffBtnTT, -10, -30, 1, 5);
GuiTooltip sdcardBtnTT(tr( "Reload SD" ));
if (Settings.wsprompt) sdcardBtnTT.SetWidescreen(Settings.widescreen);
@ -238,12 +233,12 @@ int MenuDiscList()
GuiImage sdcardImgOver(&btnsdcardOver);
sdcardImg.SetWidescreen(Settings.widescreen);
sdcardImgOver.SetWidescreen(Settings.widescreen);
GuiButton sdcardBtn(&sdcardImg, &sdcardImgOver, 0, 3, Theme.sdcard_x, Theme.sdcard_y, &trigA, &btnSoundOver,
btnClick2, 1, &sdcardBtnTT, 15, -30, 0, 5);
GuiButton sdcardBtn(&sdcardImg, &sdcardImgOver, 0, 3, Theme.sdcard_x, Theme.sdcard_y, &trigA, btnSoundOver,
btnSoundClick2, 1, &sdcardBtnTT, 15, -30, 0, 5);
GuiButton gameInfo(0, 0);
gameInfo.SetTrigger(&trig2);
gameInfo.SetSoundClick(btnClick2);
gameInfo.SetSoundClick(btnSoundClick2);
GuiTooltip favoriteBtnTT(tr( "Display favorites only" ));
if (Settings.wsprompt) favoriteBtnTT.SetWidescreen(Settings.widescreen);
@ -253,7 +248,7 @@ int MenuDiscList()
GuiImage favoriteBtnImg_g(&imgfavIcon_gray);
favoriteBtnImg_g.SetWidescreen(Settings.widescreen);
GuiButton favoriteBtn(&favoriteBtnImg_g, &favoriteBtnImg_g, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_favorite_x,
Theme.gamelist_favorite_y, &trigA, &btnSoundOver, btnClick2, 1, &favoriteBtnTT, -15, 52, 0, 3);
Theme.gamelist_favorite_y, &trigA, btnSoundOver, btnSoundClick2, 1, &favoriteBtnTT, -15, 52, 0, 3);
favoriteBtn.SetAlpha(180);
GuiTooltip searchBtnTT(tr( "Set Search-Filter" ));
@ -264,7 +259,7 @@ int MenuDiscList()
GuiImage searchBtnImg_g(&imgsearchIcon_gray);
searchBtnImg_g.SetWidescreen(Settings.widescreen);
GuiButton searchBtn(&searchBtnImg_g, &searchBtnImg_g, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_search_x,
Theme.gamelist_search_y, &trigA, &btnSoundOver, btnClick2, 1, &searchBtnTT, -15, 52, 0, 3);
Theme.gamelist_search_y, &trigA, btnSoundOver, btnSoundClick2, 1, &searchBtnTT, -15, 52, 0, 3);
searchBtn.SetAlpha(180);
const char * sortTTText = NULL;
@ -292,7 +287,7 @@ int MenuDiscList()
GuiImage sortBtnImg(sortImgData);
sortBtnImg.SetWidescreen(Settings.widescreen);
GuiButton sortBtn(&sortBtnImg, &sortBtnImg, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_abc_x, Theme.gamelist_abc_y, &trigA, &btnSoundOver, btnClick2, 1, &sortBtnTT, -15, 52, 0, 3);
GuiButton sortBtn(&sortBtnImg, &sortBtnImg, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_abc_x, Theme.gamelist_abc_y, &trigA, btnSoundOver, btnSoundClick2, 1, &sortBtnTT, -15, 52, 0, 3);
GuiTooltip listBtnTT(tr( "Display as a list" ));
if (Settings.wsprompt) listBtnTT.SetWidescreen(Settings.widescreen);
@ -302,7 +297,7 @@ int MenuDiscList()
GuiImage listBtnImg_g(&imgarrangeList_gray);
listBtnImg_g.SetWidescreen(Settings.widescreen);
GuiButton listBtn(&listBtnImg_g, &listBtnImg_g, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_list_x,
Theme.gamelist_list_y, &trigA, &btnSoundOver, btnClick2, 1, &listBtnTT, 15, 52, 1, 3);
Theme.gamelist_list_y, &trigA, btnSoundOver, btnSoundClick2, 1, &listBtnTT, 15, 52, 1, 3);
listBtn.SetAlpha(180);
GuiTooltip gridBtnTT(tr( "Display as a grid" ));
@ -313,7 +308,7 @@ int MenuDiscList()
GuiImage gridBtnImg_g(&imgarrangeGrid_gray);
gridBtnImg_g.SetWidescreen(Settings.widescreen);
GuiButton gridBtn(&gridBtnImg_g, &gridBtnImg_g, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_grid_x,
Theme.gamelist_grid_y, &trigA, &btnSoundOver, btnClick2, 1, &gridBtnTT, 15, 52, 1, 3);
Theme.gamelist_grid_y, &trigA, btnSoundOver, btnSoundClick2, 1, &gridBtnTT, 15, 52, 1, 3);
gridBtn.SetAlpha(180);
GuiTooltip carouselBtnTT(tr( "Display as a carousel" ));
@ -324,7 +319,7 @@ int MenuDiscList()
GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray);
carouselBtnImg_g.SetWidescreen(Settings.widescreen);
GuiButton carouselBtn(&carouselBtnImg_g, &carouselBtnImg_g, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_carousel_x,
Theme.gamelist_carousel_y, &trigA, &btnSoundOver, btnClick2, 1, &carouselBtnTT, 15, 52, 1, 3);
Theme.gamelist_carousel_y, &trigA, btnSoundOver, btnSoundClick2, 1, &carouselBtnTT, 15, 52, 1, 3);
carouselBtn.SetAlpha(180);
bool canUnlock = (Settings.parentalcontrol == 0 && Settings.Parental.enabled == 1);
@ -337,7 +332,7 @@ int MenuDiscList()
GuiImage lockBtnImg_g(&imgLock_gray);
lockBtnImg_g.SetWidescreen(Settings.widescreen);
GuiButton lockBtn(&lockBtnImg_g, &lockBtnImg_g, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_lock_x,
Theme.gamelist_lock_y, &trigA, &btnSoundOver, btnClick2, 1, &lockBtnTT, 15, 52, 1, 3);
Theme.gamelist_lock_y, &trigA, btnSoundOver, btnSoundClick2, 1, &lockBtnTT, 15, 52, 1, 3);
lockBtn.SetAlpha(180);
GuiTooltip unlockBtnTT(tr( "Enable Parental Control" ));
@ -363,7 +358,7 @@ int MenuDiscList()
GuiImage dvdBtnImg_g(dvdBtnImg);
dvdBtnImg_g.SetWidescreen(Settings.widescreen);
GuiButton dvdBtn(&dvdBtnImg_g, &dvdBtnImg_g, ALIGN_LEFT, ALIGN_TOP, Theme.gamelist_dvd_x, Theme.gamelist_dvd_y,
&trigA, &btnSoundOver, btnClick2, 1, &dvdBtnTT, 15, 52, 1, 3);
&trigA, btnSoundOver, btnSoundClick2, 1, &dvdBtnTT, 15, 52, 1, 3);
dvdBtn.SetAlpha(180);
GuiTooltip homebrewBtnTT(tr( "Homebrew Launcher" ));
@ -374,7 +369,7 @@ int MenuDiscList()
homebrewImg.SetWidescreen(Settings.widescreen);
homebrewImgOver.SetWidescreen(Settings.widescreen);
GuiButton homebrewBtn(&homebrewImg, &homebrewImgOver, ALIGN_LEFT, ALIGN_TOP, Theme.homebrew_x, Theme.homebrew_y,
&trigA, &btnSoundOver, btnClick2, 1, &homebrewBtnTT, 15, -30, 1, 5);
&trigA, btnSoundOver, btnSoundClick2, 1, &homebrewBtnTT, 15, -30, 1, 5);
if (Settings.GameSort & SORT_FAVORITE)
{
@ -461,12 +456,12 @@ int MenuDiscList()
if (Settings.godmode == 1 && mountMethod != 3) //only make the button have trigger & tooltip if in godmode
{
DownloadBtn.SetSoundOver(&btnSoundOver);
DownloadBtn.SetSoundOver(btnSoundOver);
DownloadBtn.SetTrigger(&trigA);
DownloadBtn.SetTrigger(&trig1);
DownloadBtn.SetToolTip(&DownloadBtnTT, 205, -30);
idBtn.SetSoundOver(&btnSoundOver);
idBtn.SetSoundOver(btnSoundOver);
idBtn.SetTrigger(&trigA);
idBtn.SetToolTip(&IDBtnTT, 205, -30);

View File

@ -25,8 +25,6 @@ int MenuInstall()
int ret, choice = 0;
char name[200];
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
GuiImageData battery(Resources::GetFile("battery.png"), Resources::GetFileSize("battery.png"));
GuiImageData batteryBar(Resources::GetFile("battery_bar.png"), Resources::GetFileSize("battery_bar.png"));
GuiImageData batteryRed(Resources::GetFile("battery_red.png"), Resources::GetFileSize("battery_red.png"));

View File

@ -43,10 +43,6 @@ int SelectPartitionMenu()
counter++;
}
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnpwroff(Resources::GetFile("wiimote_poweroff.png"), Resources::GetFileSize("wiimote_poweroff.png"));
GuiImageData btnpwroffOver(Resources::GetFile("wiimote_poweroff_over.png"), Resources::GetFileSize("wiimote_poweroff_over.png"));
GuiImageData btnhome(Resources::GetFile("menu_button.png"), Resources::GetFileSize("menu_button.png"));
@ -66,12 +62,12 @@ int SelectPartitionMenu()
poweroffBtnImg.SetWidescreen(Settings.widescreen);
poweroffBtnImgOver.SetWidescreen(Settings.widescreen);
GuiButton poweroffBtn(&poweroffBtnImg, &poweroffBtnImgOver, 0, 3, Theme.power_x, Theme.power_y, &trigA,
&btnSoundOver, btnClick2, 1);
btnSoundOver, btnSoundClick2, 1);
GuiImage exitBtnImg(&btnhome);
GuiImage exitBtnImgOver(&btnhomeOver);
exitBtnImg.SetWidescreen(Settings.widescreen);
exitBtnImgOver.SetWidescreen(Settings.widescreen);
GuiButton exitBtn(&exitBtnImg, &exitBtnImgOver, 0, 3, Theme.home_x, Theme.home_y, &trigA, &btnSoundOver, btnClick2,
GuiButton exitBtn(&exitBtnImg, &exitBtnImgOver, 0, 3, Theme.home_x, Theme.home_y, &trigA, btnSoundOver, btnSoundClick2,
1);
exitBtn.SetTrigger(&trigHome);

View File

@ -2,7 +2,6 @@
#define _MENUS_H
#include "libwiigui/gui.h"
#include "libwiigui/gui_bgm.h"
#include "language/gettext.h"
#include "prompts/PromptWindows.h"
#include "menu.h"

View File

@ -36,7 +36,7 @@ extern u8 reset;
/********************************************************************************
*Disk Browser
*********************************************************************************/
int DiscBrowse(struct discHdr * header, char * alternatedname, int alternatedname_size)
int DiscBrowse(const char * GameID, char * alternatedname, int alternatedname_size)
{
gprintf("\nDiscBrowser() started");
bool exit = false;
@ -44,7 +44,7 @@ int DiscBrowse(struct discHdr * header, char * alternatedname, int alternatednam
HaltGui();
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) header->id);
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) GameID);
if (!disc)
{
ResumeGui();
@ -98,11 +98,6 @@ int DiscBrowse(struct discHdr * header, char * alternatedname, int alternatednam
return -1;
}
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
@ -113,7 +108,7 @@ int DiscBrowse(struct discHdr * header, char * alternatedname, int alternatednam
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiText titleTxt(GameTitles.GetTitle(header), 28, ( GXColor ) {0, 0, 0, 255});
GuiText titleTxt(GameTitles.GetTitle(GameID), 28, ( GXColor ) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12, 40);
titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);
@ -132,7 +127,7 @@ int DiscBrowse(struct discHdr * header, char * alternatedname, int alternatednam
cancelBtnTxt.SetWidescreen(Settings.widescreen);
cancelBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
cancelBtn.SetScale(0.9);
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
@ -300,7 +295,7 @@ int autoSelectDolMenu(const char *id, bool force)
//Indiana Jones and the Staff of Kings (Fate of Atlantis)
if (strcmp(id, "RJ8E64") == 0)
{
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Fate of Atlantis", tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Fate of Atlantis", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -314,7 +309,7 @@ int autoSelectDolMenu(const char *id, bool force)
}
if (strcmp(id, "RJ8P64") == 0)
{
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Fate of Atlantis", tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Fate of Atlantis", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -330,7 +325,7 @@ int autoSelectDolMenu(const char *id, bool force)
//Metal Slug Anthology (Metal Slug 6)
if (strcmp(id, "RMLEH4") == 0)
{
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metal Slug 6", tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metal Slug 6", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -344,7 +339,7 @@ int autoSelectDolMenu(const char *id, bool force)
}
if (strcmp(id, "RMLP7U") == 0)
{
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metal Slug 6", tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metal Slug 6", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -367,8 +362,7 @@ int autoSelectDolMenu(const char *id, bool force)
return -1;
}
*/
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metroid Prime", "Metroid Prime 2", "Metroid Prime 3",
tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metroid Prime", "Metroid Prime 2", "Metroid Prime 3", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -394,8 +388,7 @@ int autoSelectDolMenu(const char *id, bool force)
return -1;
}
*/
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metroid Prime", "Metroid Prime 2", "Metroid Prime 3",
tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metroid Prime", "Metroid Prime 2", "Metroid Prime 3", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -417,7 +410,7 @@ int autoSelectDolMenu(const char *id, bool force)
//Rampage: Total Destruction (M1.dol=Rampage, jarvos.dol=Rampage World Tour)
if (strcmp(id, "RPGP5D") == 0)
{
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Rampage", "World Tour", tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Rampage", "World Tour", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -436,7 +429,7 @@ int autoSelectDolMenu(const char *id, bool force)
//The House Of The Dead 2 & 3 Return (only to play 2)
if (strcmp(id, "RHDE8P") == 0)
{
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "HotD 2", tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "HotD 2", tr( "Cancel" ));
switch (choice)
{
case 1:
@ -450,7 +443,7 @@ int autoSelectDolMenu(const char *id, bool force)
}
if (strcmp(id, "RHDP8P") == 0)
{
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "HotD 2", tr( "Default" ));
int choice = WindowPrompt(tr( "Select a DOL" ), 0, "HotD 2", tr( "Cancel" ));
switch (choice)
{
case 1:

View File

@ -8,7 +8,10 @@
#ifndef _DISCBROWSER_H_
#define _DISCBROWSER_H_
int DiscBrowse(struct discHdr * header, char * dolname, int dolname_size);
#include <gctypes.h>
#include "usbloader/disc.h"
int DiscBrowse(const char * GameID, char * dolname, int dolname_size);
int autoSelectDol(const char *id, bool force);
int autoSelectDolMenu(const char *id, bool force);
u8 DiscMount(struct discHdr * header);

View File

@ -71,10 +71,6 @@ int OnScreenNumpad(char * var, u32 maxlen)
GuiNumpad numpad(var, maxlen);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiTrigger trigA;
@ -89,7 +85,7 @@ int OnScreenNumpad(char * var, u32 maxlen)
okBtnTxt.SetWidescreen(Settings.widescreen);
okBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton okBtn(&okBtnImg, &okBtnImg, 0, 4, 5, -15, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton okBtn(&okBtnImg, &okBtnImg, 0, 4, 5, -15, &trigA, btnSoundOver, btnSoundClick2, 1);
okBtn.SetLabel(&okBtnTxt);
GuiText cancelBtnTxt(tr( "Cancel" ), 22, Theme.prompttext);
GuiImage cancelBtnImg(&btnOutline);
@ -98,7 +94,7 @@ int OnScreenNumpad(char * var, u32 maxlen)
cancelBtnTxt.SetWidescreen(Settings.widescreen);
cancelBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 1, 4, -5, -15, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 1, 4, -5, -15, &trigA, btnSoundOver, btnSoundClick2, 1);
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
@ -148,11 +144,6 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min)
GuiKeyboard keyboard(var, maxlen, min, Settings.keyset);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiTrigger trigA;
@ -167,7 +158,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min)
okBtnTxt.SetWidescreen(Settings.widescreen);
okBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton okBtn(&okBtnImg, &okBtnImg, 0, 4, 5, 15, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton okBtn(&okBtnImg, &okBtnImg, 0, 4, 5, 15, &trigA, btnSoundOver, btnSoundClick2, 1);
okBtn.SetLabel(&okBtnTxt);
GuiText cancelBtnTxt(tr( "Cancel" ), 22, Theme.prompttext);
GuiImage cancelBtnImg(&btnOutline);
@ -176,7 +167,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min)
cancelBtnTxt.SetWidescreen(Settings.widescreen);
cancelBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 1, 4, -5, 15, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 1, 4, -5, 15, &trigA, btnSoundOver, btnSoundClick2, 1);
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
@ -523,10 +514,6 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
@ -557,7 +544,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
btn1Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn1(&btn1Img, &btn1Img, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn1(&btn1Img, &btn1Img, 0, 3, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn1.SetLabel(&btn1Txt);
btn1.SetState(STATE_SELECTED);
@ -568,7 +555,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
btn2Txt.SetWidescreen(Settings.widescreen);
btn2Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn2(&btn2Img, &btn2Img, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn2(&btn2Img, &btn2Img, 0, 3, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn2.SetLabel(&btn2Txt);
if (!btn3Label && !btn4Label) btn2.SetTrigger(&trigB);
@ -579,7 +566,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
btn3Txt.SetWidescreen(Settings.widescreen);
btn3Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn3(&btn3Img, &btn3Img, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn3(&btn3Img, &btn3Img, 0, 3, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn3.SetLabel(&btn3Txt);
if (!btn4Label) btn3.SetTrigger(&trigB);
@ -590,7 +577,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
btn4Txt.SetWidescreen(Settings.widescreen);
btn4Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn4(&btn4Img, &btn4Img, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn4(&btn4Img, &btn4Img, 0, 3, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn4.SetLabel(&btn4Txt);
if (btn4Label) btn4.SetTrigger(&trigB);
@ -823,11 +810,6 @@ int WindowExitPrompt()
GuiWindow promptWindow(640, 480);
promptWindow.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
promptWindow.SetPosition(0, 0);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData top(exit_top_png, exit_top_png_size);
GuiImageData topOver(exit_top_over_png, exit_top_over_png_size);
GuiImageData bottom(exit_bottom_png, exit_bottom_png_size);
@ -911,7 +893,7 @@ int WindowExitPrompt()
GuiImage btn1Img(&top);
GuiImage btn1OverImg(&topOver);
GuiButton btn1(&btn1Img, &btn1OverImg, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2, 0);
GuiButton btn1(&btn1Img, &btn1OverImg, 0, 3, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 0);
btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
GuiText btn2Txt(tr( "Back to Loader" ), 28, ( GXColor )
@ -922,7 +904,7 @@ int WindowExitPrompt()
btn2Txt.SetWidescreen(Settings.widescreen);
btn2Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn2(&btn2Img, &btn2Img, 2, 5, -150, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn2(&btn2Img, &btn2Img, 2, 5, -150, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn2.SetLabel(&btn2Txt);
btn2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 50);
btn2.SetRumble(false);
@ -936,7 +918,7 @@ int WindowExitPrompt()
btn3Txt.SetWidescreen(Settings.widescreen);
btn3Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn3(&btn3Img, &btn3Img, 2, 5, 150, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn3(&btn3Img, &btn3Img, 2, 5, 150, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn3.SetLabel(&btn3Txt);
btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 50);
btn3.SetRumble(false);
@ -944,7 +926,7 @@ int WindowExitPrompt()
GuiImage btn4Img(&bottom);
GuiImage btn4OverImg(&bottomOver);
GuiButton btn4(&btn4Img, &btn4OverImg, 0, 4, 0, 0, &trigA, &btnSoundOver, btnClick2, 0);
GuiButton btn4(&btn4Img, &btn4OverImg, 0, 4, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 0);
btn4.SetTrigger(&trigB);
btn4.SetTrigger(&trigHome);
btn4.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 50);
@ -1156,10 +1138,6 @@ int GameWindowPrompt()
GuiWindow promptWindow(472, 320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
@ -1209,8 +1187,8 @@ int GameWindowPrompt()
// nameBtn.SetLabelOver(&nameTxt);
nameBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
nameBtn.SetPosition(0, -122);
nameBtn.SetSoundOver(&btnSoundOver);
nameBtn.SetSoundClick(btnClick2);
nameBtn.SetSoundOver(btnSoundOver);
nameBtn.SetSoundClick(btnSoundClick2);
if (!mountMethod) nameBtn.SetToolTip(&nameBtnTT, 24, -30, ALIGN_LEFT);
if (Settings.godmode == 1 && !mountMethod)
@ -1244,8 +1222,8 @@ int GameWindowPrompt()
btn1.SetPosition(0, -20);
btn1.SetImage(&diskImg);
btn1.SetSoundOver(&btnSoundOver);
btn1.SetSoundClick(btnClick2);
btn1.SetSoundOver(btnSoundOver);
btn1.SetSoundClick(btnSoundClick2);
btn1.SetTrigger(&trigA);
btn1.SetState(STATE_SELECTED);
@ -1256,7 +1234,7 @@ int GameWindowPrompt()
btn2Txt.SetWidescreen(Settings.widescreen);
btn2Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn2(&btn2Img, &btn2Img, 1, 5, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn2(&btn2Img, &btn2Img, 1, 5, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
if (Settings.godmode == 1 && mountMethod != 2 && mountMethod != 3)
{
btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
@ -1278,7 +1256,7 @@ int GameWindowPrompt()
btn3Txt.SetWidescreen(Settings.widescreen);
btn3Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn3(&btn3Img, &btn3Img, 0, 4, 50, -40, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn3(&btn3Img, &btn3Img, 0, 4, 50, -40, &trigA, btnSoundOver, btnSoundClick2, 1);
btn3.SetLabel(&btn3Txt);
GuiImage btnFavoriteImg1;
@ -1292,25 +1270,25 @@ int GameWindowPrompt()
GuiImage btnFavoriteImg5;
btnFavoriteImg5.SetWidescreen(Settings.widescreen);
//GuiButton btnFavorite(&btnFavoriteImg,&btnFavoriteImg, 2, 5, -125, -60, &trigA, &btnSoundOver, &btnClick,1);
//GuiButton btnFavorite(&btnFavoriteImg,&btnFavoriteImg, 2, 5, -125, -60, &trigA, btnSoundOver, &btnClick,1);
GuiButton btnFavorite1(imgFavorite.GetWidth(), imgFavorite.GetHeight());
GuiButton btnFavorite2(imgFavorite.GetWidth(), imgFavorite.GetHeight());
GuiButton btnFavorite3(imgFavorite.GetWidth(), imgFavorite.GetHeight());
GuiButton btnFavorite4(imgFavorite.GetWidth(), imgFavorite.GetHeight());
GuiButton btnFavorite5(imgFavorite.GetWidth(), imgFavorite.GetHeight());
SetupFavoriteButton(&btnFavorite1, -198, &btnFavoriteImg1, &btnSoundOver, btnClick2, &trigA);
SetupFavoriteButton(&btnFavorite2, -171, &btnFavoriteImg2, &btnSoundOver, btnClick2, &trigA);
SetupFavoriteButton(&btnFavorite3, -144, &btnFavoriteImg3, &btnSoundOver, btnClick2, &trigA);
SetupFavoriteButton(&btnFavorite4, -117, &btnFavoriteImg4, &btnSoundOver, btnClick2, &trigA);
SetupFavoriteButton(&btnFavorite5, -90, &btnFavoriteImg5, &btnSoundOver, btnClick2, &trigA);
SetupFavoriteButton(&btnFavorite1, -198, &btnFavoriteImg1, btnSoundOver, btnSoundClick2, &trigA);
SetupFavoriteButton(&btnFavorite2, -171, &btnFavoriteImg2, btnSoundOver, btnSoundClick2, &trigA);
SetupFavoriteButton(&btnFavorite3, -144, &btnFavoriteImg3, btnSoundOver, btnSoundClick2, &trigA);
SetupFavoriteButton(&btnFavorite4, -117, &btnFavoriteImg4, btnSoundOver, btnSoundClick2, &trigA);
SetupFavoriteButton(&btnFavorite5, -90, &btnFavoriteImg5, btnSoundOver, btnSoundClick2, &trigA);
GuiImage btnLeftImg(&imgLeft);
if (Settings.wsprompt)
{
btnLeftImg.SetWidescreen(Settings.widescreen);
}
GuiButton btnLeft(&btnLeftImg, &btnLeftImg, 0, 5, 20, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btnLeft(&btnLeftImg, &btnLeftImg, 0, 5, 20, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btnLeft.SetTrigger(&trigL);
btnLeft.SetTrigger(&trigMinus);
@ -1319,7 +1297,7 @@ int GameWindowPrompt()
{
btnRightImg.SetWidescreen(Settings.widescreen);
}
GuiButton btnRight(&btnRightImg, &btnRightImg, 1, 5, -20, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btnRight(&btnRightImg, &btnRightImg, 1, 5, -20, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btnRight.SetTrigger(&trigR);
btnRight.SetTrigger(&trigPlus);
@ -1387,7 +1365,7 @@ int GameWindowPrompt()
const u8 *gameSoundData = LoadBannerSound(header->id, &gameSoundDataLen);
if (gameSoundData)
{
gameSound = new GuiSound(gameSoundData, gameSoundDataLen, Settings.gamesoundvolume, false, true);
gameSound = new GuiSound(gameSoundData, gameSoundDataLen, Settings.gamesoundvolume, true);
bgMusic->SetVolume(0);
if (Settings.gamesound == 2) gameSound->SetLoop(1);
gameSound->Play();
@ -1619,7 +1597,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
changed = 1;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected + 1) % gameList.size();
btnRight.ResetState();
break;
@ -1629,7 +1607,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50);
changed = 2;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected - 1 + gameList.size()) % gameList.size();
btnLeft.ResetState();
break;
@ -1639,7 +1617,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50);
changed = 2;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected - 1 + gameList.size()) % gameList.size();
btnRight.ResetState();
break;
@ -1649,7 +1627,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
changed = 1;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected + 1) % gameList.size();
btnLeft.ResetState();
break;
@ -1659,7 +1637,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50);
changed = 2;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected + 1) % gameList.size();
btnRight.ResetState();
break;
@ -1669,7 +1647,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
changed = 1;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected - 1 + gameList.size()) % gameList.size();
btnLeft.ResetState();
break;
@ -1679,7 +1657,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
changed = 1;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected - 1 + gameList.size()) % gameList.size();
btnRight.ResetState();
break;
@ -1689,7 +1667,7 @@ int GameWindowPrompt()
{
promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50);
changed = 2;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected + 1) % gameList.size();
btnLeft.ResetState();
break;
@ -1699,7 +1677,7 @@ int GameWindowPrompt()
{
// diskImg.SetBetaRotateEffect(45, 90);
changed = 3;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected + 1) % gameList.size();
btnRight.ResetState();
break;
@ -1710,7 +1688,7 @@ int GameWindowPrompt()
// diskImg.SetBetaRotateEffect(-45, 90);
// promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 1/*50*/);
changed = 4;
btnClick2->Play();
btnSoundClick2->Play();
gameSelected = (gameSelected - 1 + gameList.size()) % gameList.size();
btnLeft.ResetState();
break;
@ -1752,9 +1730,6 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
GuiWindow promptWindow(472, 320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
@ -1784,7 +1759,7 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
btn1Txt.SetWidescreen(Settings.widescreen);
btn1Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn1(&btn1Img, &btn1Img, 1, 5, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn1(&btn1Img, &btn1Img, 1, 5, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
if (btn2Label)
{
@ -1808,7 +1783,7 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
btn2Txt.SetWidescreen(Settings.widescreen);
btn2Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn2(&btn2Img, &btn2Img, 1, 4, -20, -25, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn2(&btn2Img, &btn2Img, 1, 4, -20, -25, &trigA, btnSoundOver, btnSoundClick2, 1);
btn2.SetLabel(&btn2Txt);
if (Settings.wsprompt && Settings.widescreen) /////////////adjust buttons for widescreen
@ -1971,11 +1946,6 @@ bool SearchMissingImages(int choice2)
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
GuiTrigger trigA;
@ -2103,11 +2073,6 @@ bool NetworkInitPrompt()
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
GuiTrigger trigA;
@ -2136,7 +2101,7 @@ bool NetworkInitPrompt()
btn1Txt.SetWidescreen(Settings.widescreen);
btn1Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -45, &trigA, btnSoundOver, btnSoundClick2, 1);
btn1.SetLabel(&btn1Txt);
btn1.SetState(STATE_SELECTED);
@ -2209,11 +2174,6 @@ int ProgressDownloadWindow(int choice2)
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
GuiTrigger trigA;
@ -2268,7 +2228,7 @@ int ProgressDownloadWindow(int choice2)
btn1Txt.SetWidescreen(Settings.widescreen);
btn1Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -45, &trigA, btnSoundOver, btnSoundClick2, 1);
btn1.SetLabel(&btn1Txt);
btn1.SetState(STATE_SELECTED);
@ -2812,11 +2772,6 @@ int ProgressUpdateWindow()
promptWindow.SetAlignment( ALIGN_CENTRE, ALIGN_MIDDLE );
promptWindow.SetPosition( 0, -10 );
GuiSound btnSoundOver( button_over_pcm, button_over_pcm_size, Settings.sfxvolume );
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if ( !btnClick2 ) btnClick2 = new GuiSound( button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume );
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
char imgPath[100];
snprintf( imgPath, sizeof( imgPath ), "%sbutton_dialogue_box.png", Settings.theme_path );
GuiImageData btnOutline( imgPath, button_dialogue_box_png );
@ -2880,7 +2835,7 @@ int ProgressUpdateWindow()
btn1Txt.SetWidescreen( Settings.widescreen );
btn1Img.SetWidescreen( Settings.widescreen );
}
GuiButton btn1( &btn1Img, &btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, btnClick2, 1 );
GuiButton btn1( &btn1Img, &btn1Img, 2, 4, 0, -40, &trigA, btnSoundOver, btnSoundClick2, 1 );
btn1.SetLabel( &btn1Txt );
btn1.SetState( STATE_SELECTED );
@ -3180,11 +3135,6 @@ int ProgressUpdateWindow()
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
GuiTrigger trigA;
@ -3242,7 +3192,7 @@ int ProgressUpdateWindow()
btn1Txt.SetWidescreen(Settings.widescreen);
btn1Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -40, &trigA, btnSoundOver, btnSoundClick2, 1);
btn1.SetLabel(&btn1Txt);
btn1.SetState(STATE_SELECTED);
@ -3575,11 +3525,6 @@ int CodeDownload(const char *id)
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
GuiTrigger trigA;
@ -3613,7 +3558,7 @@ int CodeDownload(const char *id)
btn1Txt.SetWidescreen(Settings.widescreen);
btn1Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn1(&btn1Img, &btn1Img, 2, 4, 0, -40, &trigA, btnSoundOver, btnSoundClick2, 1);
btn1.SetLabel(&btn1Txt);
btn1.SetState(STATE_SELECTED);
@ -3760,11 +3705,6 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
GuiTrigger trigD;
trigD.SetButtonOnlyTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox(Resources::GetFile("dialogue_box.png"), Resources::GetFileSize("dialogue_box.png"));
GuiImageData whiteBox(Resources::GetFile("bg_options.png"), Resources::GetFileSize("bg_options.png"));
@ -3790,7 +3730,7 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
arrowUpBtn.SetTrigger(&trigA);
arrowUpBtn.SetTrigger(&trigU);
arrowUpBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130);
arrowUpBtn.SetSoundClick(btnClick2);
arrowUpBtn.SetSoundClick(btnSoundClick2);
GuiButton arrowDownBtn(arrowDownImg.GetWidth(), arrowDownImg.GetHeight());
arrowDownBtn.SetImage(&arrowDownImg);
@ -3799,7 +3739,7 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
arrowDownBtn.SetTrigger(&trigA);
arrowDownBtn.SetTrigger(&trigD);
arrowDownBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130);
arrowDownBtn.SetSoundClick(btnClick2);
arrowDownBtn.SetSoundClick(btnSoundClick2);
GuiImageData *iconData = NULL;
GuiImage *iconImg = NULL;
@ -3874,7 +3814,7 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
btn1Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn1(&btn1Img, &btn1Img, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn1(&btn1Img, &btn1Img, 0, 3, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn1.SetLabel(&btn1Txt);
btn1.SetState(STATE_SELECTED);
@ -3885,7 +3825,7 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
btn2Txt.SetWidescreen(Settings.widescreen);
btn2Img.SetWidescreen(Settings.widescreen);
}
GuiButton btn2(&btn2Img, &btn2Img, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton btn2(&btn2Img, &btn2Img, 0, 3, 0, 0, &trigA, btnSoundOver, btnSoundClick2, 1);
btn2.SetLabel(&btn2Txt);
btn2.SetTrigger(&trigB);

View File

@ -124,10 +124,6 @@ bool TitleSelector(char output[])
bool exit = false;
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
@ -150,7 +146,7 @@ bool TitleSelector(char output[])
cancelBtnTxt.SetWidescreen(Settings.widescreen);
cancelBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
@ -350,11 +346,6 @@ int TitleBrowser()
if (IsNetworkInit()) ResumeNetworkWait();
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
@ -385,7 +376,7 @@ int TitleBrowser()
cancelBtnTxt.SetWidescreen(Settings.widescreen);
cancelBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
cancelBtn.SetScale(0.9);
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);

View File

@ -295,21 +295,11 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
}
int menu = MENU_NONE;
/*
GuiText titleTxt("Browse Files", 28, (GXColor){0, 0, 0, 230});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(70,20);
*/
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData folderImgData(Resources::GetFile("icon_folder.png"), Resources::GetFileSize("icon_folder.png"));
GuiImage folderImg(&folderImgData);
GuiButton folderBtn(folderImg.GetWidth(), folderImg.GetHeight());
@ -320,8 +310,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
folderBtn.SetEffectGrow();
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiText ExitBtnTxt(tr( "Cancel" ), 24, ( GXColor )
{ 0, 0, 0, 255});
GuiText ExitBtnTxt(tr( "Cancel" ), 24, ( GXColor ) {0, 0, 0, 255});
GuiImage ExitBtnImg(&btnOutline);
if (Settings.wsprompt)
{
@ -337,8 +326,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
ExitBtn.SetTrigger(&trigB);
ExitBtn.SetEffectGrow();
GuiText usbBtnTxt(browsers[(curDevice + 1) % browsers.size()].rootdir, 24, ( GXColor )
{ 0, 0, 0, 255});
GuiText usbBtnTxt(browsers[(curDevice + 1) % browsers.size()].rootdir, 24, ( GXColor ) {0, 0, 0, 255});
GuiImage usbBtnImg(&btnOutline);
if (Settings.wsprompt)
{
@ -360,7 +348,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
okBtnTxt.SetWidescreen(Settings.widescreen);
okBtnImg.SetWidescreen(Settings.widescreen);
}
GuiButton okBtn(&okBtnImg, &okBtnImg, 0, 4, 40, -35, &trigA, &btnSoundOver, btnClick2, 1);
GuiButton okBtn(&okBtnImg, &okBtnImg, 0, 4, 40, -35, &trigA, btnSoundOver, btnSoundClick2, 1);
okBtn.SetLabel(&okBtnTxt);
GuiFileBrowser fileBrowser(396, 248);
@ -368,8 +356,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
fileBrowser.SetPosition(0, 120);
GuiImageData Address(Resources::GetFile("addressbar_textbox.png"), Resources::GetFileSize("addressbar_textbox.png"));
GuiText AdressText((char*) NULL, 20, ( GXColor )
{ 0, 0, 0, 255});
GuiText AdressText((char*) NULL, 20, ( GXColor ) {0, 0, 0, 255});
AdressText.SetTextf("%s%s", browser->rootdir, browser->dir);
AdressText.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
AdressText.SetPosition(20, 0);

View File

@ -137,9 +137,6 @@ int showGameInfo(char *ID)
txtWindow.SetAlignment(ALIGN_CENTRE, ALIGN_RIGHT);
txtWindow.SetPosition(95, 55);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData dialogBox1(Resources::GetFile("gameinfo1.png"), Resources::GetFileSize("gameinfo1.png"));
GuiImageData dialogBox2(Resources::GetFile("gameinfo1a.png"), Resources::GetFileSize("gameinfo1a.png"));
@ -305,7 +302,7 @@ int showGameInfo(char *ID)
gameinfoWindow.Append(dialogBoxImg2);
gameinfoWindow.Append(dialogBoxImg3);
gameinfoWindow.Append(dialogBoxImg4);
char imgPath[150];
snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID);
cover = new GuiImageData(imgPath); //load full id image

File diff suppressed because it is too large Load Diff

View File

@ -23,10 +23,6 @@
extern u8 shutdown;
extern u8 reset;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/****************************************************************************
* MenuOGG
@ -95,11 +91,6 @@ int MenuLanguageSelect()
int scrollon;
int returnhere = 0;
GuiSound btnSoundOver( button_over_pcm, button_over_pcm_size, Settings.sfxvolume );
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
if ( !btnClick2 ) btnClick2 = new GuiSound( button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume );
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
@ -127,8 +118,8 @@ int MenuLanguageSelect()
pathBtn.SetAlignment( ALIGN_CENTRE, ALIGN_TOP );
pathBtn.SetPosition( 0, 28 );
pathBtn.SetLabel( &titleTxt );
pathBtn.SetSoundOver( &btnSoundOver );
pathBtn.SetSoundClick( btnClick2 );
pathBtn.SetSoundOver( btnSoundOver );
pathBtn.SetSoundClick( btnSoundClick2 );
pathBtn.SetTrigger( &trigA );
pathBtn.SetEffectGrow();
@ -149,8 +140,8 @@ int MenuLanguageSelect()
backBtn.SetPosition( -190, 400 );
backBtn.SetLabel( &backBtnTxt );
backBtn.SetImage( &backBtnImg );
backBtn.SetSoundOver( &btnSoundOver );
backBtn.SetSoundClick( btnClick2 );
backBtn.SetSoundOver( btnSoundOver );
backBtn.SetSoundClick( btnSoundClick2 );
backBtn.SetTrigger( &trigA );
backBtn.SetTrigger( &trigB );
backBtn.SetEffectGrow();
@ -168,8 +159,8 @@ int MenuLanguageSelect()
defaultBtn.SetPosition( 190, 400 );
defaultBtn.SetLabel( &defaultBtnTxt );
defaultBtn.SetImage( &defaultBtnImg );
defaultBtn.SetSoundOver( &btnSoundOver );
defaultBtn.SetSoundClick( btnClick2 );
defaultBtn.SetSoundOver( btnSoundOver );
defaultBtn.SetSoundClick( btnSoundClick2 );
defaultBtn.SetTrigger( &trigA );
defaultBtn.SetEffectGrow();
@ -186,8 +177,8 @@ int MenuLanguageSelect()
updateBtn.SetPosition( 0, 400 );
updateBtn.SetLabel( &updateBtnTxt );
updateBtn.SetImage( &updateBtnImg );
updateBtn.SetSoundOver( &btnSoundOver );
updateBtn.SetSoundClick( btnClick2 );
updateBtn.SetSoundOver( btnSoundOver );
updateBtn.SetSoundClick( btnSoundClick2 );
updateBtn.SetTrigger( &trigA );
updateBtn.SetEffectGrow();

View File

@ -0,0 +1,252 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include "CustomPathsSM.hpp"
#include "settings/CSettings.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
#include "prompts/filebrowser.h"
#include "themes/CTheme.h"
CustomPathsSM::CustomPathsSM()
: SettingsMenu(tr("Custom Paths"), &GuiOptions, MENU_NONE)
{
int Idx = 0;
Options->SetName(Idx++, tr("3D Cover Path"));
Options->SetName(Idx++, tr("2D Cover Path"));
Options->SetName(Idx++, tr("Disc Artwork Path"));
Options->SetName(Idx++, tr("Theme Path"));
Options->SetName(Idx++, tr("WiiTDB Path"));
Options->SetName(Idx++, tr("Update Path"));
Options->SetName(Idx++, tr("GCT Cheatcodes Path"));
Options->SetName(Idx++, tr("TXT Cheatcodes Path"));
Options->SetName(Idx++, tr("DOL Path"));
Options->SetName(Idx++, tr("Homebrew Apps Path"));
Options->SetName(Idx++, tr("Theme Download Path"));
Options->SetName(Idx++, tr("BCA Codes Path"));
Options->SetName(Idx++, tr("WIP Patches Path"));
SetOptionValues();
}
void CustomPathsSM::SetOptionValues()
{
int Idx = 0;
//! Settings: 3D Cover Path
Options->SetValue(Idx++, Settings.covers_path);
//! Settings: 2D Cover Path
Options->SetValue(Idx++, Settings.covers2d_path);
//! Settings: Disc Artwork Path
Options->SetValue(Idx++, Settings.disc_path);
//! Settings: Theme Path
Options->SetValue(Idx++, Settings.theme_path);
//! Settings: WiiTDB Path
Options->SetValue(Idx++, Settings.titlestxt_path);
//! Settings: Update Path
Options->SetValue(Idx++, Settings.update_path);
//! Settings: GCT Cheatcodes Path
Options->SetValue(Idx++, Settings.Cheatcodespath);
//! Settings: TXT Cheatcodes Path
Options->SetValue(Idx++, Settings.TxtCheatcodespath);
//! Settings: DOL Path
Options->SetValue(Idx++, Settings.dolpath);
//! Settings: Homebrew Apps Path
Options->SetValue(Idx++, Settings.homebrewapps_path);
//! Settings: Theme Download Path
Options->SetValue(Idx++, Settings.theme_downloadpath);
//! Settings: BCA Codes Path
Options->SetValue(Idx++, Settings.BcaCodepath);
//! Settings: WIP Patches Path
Options->SetValue(Idx++, Settings.WipCodepath);
}
int CustomPathsSM::GetMenuInternal()
{
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: 3D Cover Path
if (ret == ++Idx)
{
titleTxt->SetText(tr( "3D Cover Path" ));
ChangePath(Settings.covers_path, sizeof(Settings.covers_path));
}
//! Settings: 2D Cover Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "2D Cover Path" ));
ChangePath(Settings.covers2d_path, sizeof(Settings.covers2d_path));
}
//! Settings: Disc Artwork Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "Disc Artwork Path" ));
ChangePath(Settings.disc_path, sizeof(Settings.disc_path));
}
//! Settings: Theme Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "Theme Path" ));
int result = ChangePath(Settings.theme_path, sizeof(Settings.theme_path));
if (result == 1)
{
HaltGui();
mainWindow->Remove(bgImg);
Theme.Load(Settings.theme_path);
if(pointer[0]) delete pointer[0];
if(pointer[1]) delete pointer[1];
if(pointer[2]) delete pointer[2];
if(pointer[3]) delete pointer[3];
pointer[0] = Resources::GetImageData("player1_point.png");
pointer[1] = Resources::GetImageData("player2_point.png");
pointer[2] = Resources::GetImageData("player3_point.png");
pointer[3] = Resources::GetImageData("player4_point.png");
if(background) delete background;
background = Resources::GetImageData(Settings.widescreen ? "wbackground.png" : "background.png");
if(bgImg) delete bgImg;
bgImg = new GuiImage(background);
mainWindow->Append(bgImg);
ResumeGui();
return MENU_SETTINGS;
}
}
//! Settings: WiiTDB Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "WiiTDB Path" ));
ChangePath(Settings.titlestxt_path, sizeof(Settings.titlestxt_path));
}
//! Settings: Update Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "Update Path" ));
ChangePath(Settings.update_path, sizeof(Settings.update_path));
}
//! Settings: GCT Cheatcodes Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "GCT Cheatcodes Path" ));
ChangePath(Settings.Cheatcodespath, sizeof(Settings.Cheatcodespath));
}
//! Settings: TXT Cheatcodes Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "TXT Cheatcodes Path" ));
ChangePath(Settings.TxtCheatcodespath, sizeof(Settings.TxtCheatcodespath));
}
//! Settings: DOL Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "DOL Path" ));
ChangePath(Settings.dolpath, sizeof(Settings.dolpath));
}
//! Settings: Homebrew Apps Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "Homebrew Apps Path" ));
ChangePath(Settings.homebrewapps_path, sizeof(Settings.homebrewapps_path));
}
//! Settings: Theme Download Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "Theme Download Path" ));
ChangePath(Settings.theme_downloadpath, sizeof(Settings.theme_downloadpath));
}
//! Settings: BCA Codes Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "BCA Codes Path" ));
ChangePath(Settings.BcaCodepath, sizeof(Settings.BcaCodepath));
}
//! Settings: WIP Patches Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "WIP Patches Path" ));
ChangePath(Settings.WipCodepath, sizeof(Settings.WipCodepath));
}
//! Global set back of the titleTxt after a change
titleTxt->SetText(tr( "Custom Paths" ));
SetOptionValues();
return MENU_NONE;
}
int CustomPathsSM::ChangePath(char * SettingsPath, int SizeOfPath)
{
char entered[300];
snprintf(entered, sizeof(entered), SettingsPath);
HaltGui();
GuiWindow * parent = (GuiWindow *) parentElement;
if(parent) parent->SetState(STATE_DISABLED);
this->SetState(STATE_DEFAULT);
this->Remove(optionBrowser);
ResumeGui();
int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES);
if(parent) parent->SetState(STATE_DEFAULT);
this->Append(optionBrowser);
if (result == 1)
{
if (entered[strlen(entered)-1] != '/')
strcat(entered, "/");
snprintf(SettingsPath, SizeOfPath, entered);
WindowPrompt(tr( "Path Changed" ), 0, tr( "OK" ));
}
return result;
}

View File

@ -0,0 +1,43 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef CUSTOMPATHS_MENU_HPP_
#define CUSTOMPATHS_MENU_HPP_
#include "SettingsMenu.hpp"
class CustomPathsSM : public SettingsMenu
{
public:
CustomPathsSM();
virtual int GetType() { return CCustomPathsSM; };
protected:
void SetOptionValues();
int GetMenuInternal();
int ChangePath(char * SettingsPath, int SizeOfPath);
OptionList GuiOptions;
};
#endif

View File

@ -0,0 +1,462 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <string.h>
#include <unistd.h>
#include "FlyingButtonsMenu.hpp"
#include "utils/StringTools.h"
#include "language/gettext.h"
#include "themes/CTheme.h"
#include "menu/menus.h"
#include "sys.h"
#define FADE_SPEED 20
#define SLIDE_SPEED 35
#define DISPLAY_BUTTONS 4
FlyingButtonsMenu::FlyingButtonsMenu(const char * menu_title)
: GuiWindow(screenwidth, screenheight)
{
currentPage = 0;
returnMenu = MENU_NONE;
CurrentMenu = NULL;
titleTxt = NULL;
GoLeftImg = NULL;
GoLeftBtn = NULL;
GoRightImg = NULL;
GoRightBtn = NULL;
MenuTitle = menu_title ? menu_title : " ";
trigA = new GuiTrigger();
trigHome = new GuiTrigger();
trigB = new GuiTrigger();
trigL = new GuiTrigger();
trigR = new GuiTrigger();
trigMinus = new GuiTrigger();
trigPlus = new GuiTrigger();
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigHome->SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
trigL->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
trigR->SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
trigPlus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
btnOutline = Resources::GetImageData("button_dialogue_box.png");
settingsbg = Resources::GetImageData("settings_background.png");
MainButtonImgData = Resources::GetImageData("settings_title.png");
MainButtonImgOverData = Resources::GetImageData("settings_title_over.png");
PageindicatorImgData = Resources::GetImageData("pageindicator.png");
arrow_left = Resources::GetImageData("startgame_arrow_left.png");
arrow_right = Resources::GetImageData("startgame_arrow_right.png");
settingsbackground = new GuiImage(settingsbg);
Append(settingsbackground);
homeBtn = new GuiButton(1, 1);
homeBtn->SetTrigger(trigHome);
Append(homeBtn);
backBtnTxt = new GuiText(tr( "Back" ), 22, Theme.prompttext);
backBtnTxt->SetMaxWidth(btnOutline->GetWidth() - 30);
backBtnImg = new GuiImage(btnOutline);
if (Settings.wsprompt == ON)
{
backBtnTxt->SetWidescreen(Settings.widescreen);
backBtnImg->SetWidescreen(Settings.widescreen);
}
backBtn = new GuiButton(backBtnImg, backBtnImg, 2, 3, -195, 400, trigA, btnSoundOver, btnSoundClick2, 1);
backBtn->SetLabel(backBtnTxt);
backBtn->SetTrigger(trigB);
Append(backBtn);
SetEffect(EFFECT_FADE, FADE_SPEED);
}
FlyingButtonsMenu::~FlyingButtonsMenu()
{
ResumeGui();
SetEffect(EFFECT_FADE, -FADE_SPEED);
while(this->GetEffect() > 0) usleep(100);
HaltGui();
if(parentElement)
((GuiWindow *) parentElement)->Remove(this);
RemoveAll();
HideMenu();
delete trigA;
delete trigHome;
delete trigB;
delete trigL;
delete trigR;
delete trigMinus;
delete trigPlus;
delete settingsbackground;
delete homeBtn;
delete btnOutline;
delete settingsbg;
delete MainButtonImgData;
delete MainButtonImgOverData;
delete PageindicatorImgData;
delete arrow_left;
delete arrow_right;
delete backBtnTxt;
delete backBtnImg;
delete backBtn;
ResumeGui();
}
void FlyingButtonsMenu::SetPageIndicators()
{
HaltGui();
for(u32 i = 0; i < PageIndicatorBtn.size(); ++i)
{
Remove(PageIndicatorBtn[i]);
delete PageindicatorImg[i];
delete PageindicatorTxt[i];
delete PageIndicatorBtn[i];
}
PageindicatorImg.clear();
PageindicatorTxt.clear();
PageIndicatorBtn.clear();
int IndicatorCount = ceil(MainButton.size()/(1.0f*DISPLAY_BUTTONS));
for(int i = 0; i < IndicatorCount; ++i)
{
PageindicatorImg.push_back(new GuiImage(PageindicatorImgData));
PageindicatorTxt.push_back(new GuiText(fmt("%i", i), 22, ( GXColor ) {0, 0, 0, 255}));
PageIndicatorBtn.push_back(new GuiButton(PageindicatorImgData->GetWidth(), PageindicatorImgData->GetHeight()));
PageIndicatorBtn[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
PageIndicatorBtn[i]->SetPosition(270-IndicatorCount*35+35*i, 400);
PageIndicatorBtn[i]->SetImage(PageindicatorImg[i]);
PageIndicatorBtn[i]->SetLabel(PageindicatorTxt[i]);
PageIndicatorBtn[i]->SetSoundOver(btnSoundOver);
PageIndicatorBtn[i]->SetSoundClick(btnSoundClick);
PageIndicatorBtn[i]->SetTrigger(trigA);
PageIndicatorBtn[i]->SetEffectGrow();
PageIndicatorBtn[i]->SetAlpha(i == currentPage ? 255 : 50);
Append(PageIndicatorBtn[i]);
}
}
void FlyingButtonsMenu::SetMainButton(int position, const char * ButtonText, GuiImageData * imageData, GuiImageData * imageOver)
{
//! Don't allow operating gui mode while adding/setting the buttons
HaltGui();
if(position < (int) MainButton.size())
{
delete MainButtonImg[position];
delete MainButtonImgOver[position];
delete MainButtonTxt[position];
delete MainButton[position];
}
else
{
MainButtonImg.resize(position+1);
MainButtonImgOver.resize(position+1);
MainButtonTxt.resize(position+1);
MainButton.resize(position+1);
}
MainButtonImg[position] = new GuiImage(imageData);
MainButtonImgOver[position] = new GuiImage(imageOver);
MainButtonTxt[position] = new GuiText(ButtonText, 22, ( GXColor ) {0, 0, 0, 255});
MainButtonTxt[position]->SetMaxWidth(MainButtonImg[position]->GetWidth());
MainButton[position] = new GuiButton(imageData->GetWidth(), imageData->GetHeight());
MainButton[position]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton[position]->SetPosition(0, 90+(position % DISPLAY_BUTTONS)*70);
MainButton[position]->SetImage(MainButtonImg[position]);
MainButton[position]->SetImageOver(MainButtonImgOver[position]);
MainButton[position]->SetLabel(MainButtonTxt[position]);
MainButton[position]->SetSoundOver(btnSoundOver);
MainButton[position]->SetSoundClick(btnSoundClick);
MainButton[position]->SetEffectGrow();
MainButton[position]->SetTrigger(trigA);
}
void FlyingButtonsMenu::HideMenu()
{
HaltGui();
if(titleTxt)
Remove(titleTxt);
if(GoLeftBtn)
Remove(GoLeftBtn);
if(GoRightBtn)
Remove(GoRightBtn);
if(titleTxt)
delete titleTxt;
if(GoLeftImg)
delete GoLeftImg;
if(GoLeftBtn)
delete GoLeftBtn;
if(GoRightImg)
delete GoRightImg;
if(GoRightBtn)
delete GoRightBtn;
titleTxt = NULL;
GoLeftImg = NULL;
GoLeftBtn = NULL;
GoRightImg = NULL;
GoRightBtn = NULL;
for(u32 i = 0; i < MainButton.size(); ++i)
{
Remove(MainButton[i]);
delete MainButtonImg[i];
delete MainButtonImgOver[i];
delete MainButtonTxt[i];
delete MainButton[i];
}
for(u32 i = 0; i < PageIndicatorBtn.size(); ++i)
{
Remove(PageIndicatorBtn[i]);
delete PageindicatorImg[i];
delete PageindicatorTxt[i];
delete PageIndicatorBtn[i];
}
PageindicatorImg.clear();
PageindicatorTxt.clear();
PageIndicatorBtn.clear();
MainButtonImg.clear();
MainButtonImgOver.clear();
MainButtonTxt.clear();
MainButton.clear();
}
void FlyingButtonsMenu::ShowMenu()
{
//! Free memory if not done yet because new is allocated
HideMenu();
titleTxt = new GuiText(MenuTitle.c_str(), 28, ( GXColor ) {0, 0, 0, 255});
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(0, 40);
Append(titleTxt);
GoLeftImg = new GuiImage(arrow_left);
GoLeftBtn = new GuiButton(GoLeftImg->GetWidth(), GoLeftImg->GetHeight());
GoLeftBtn->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
GoLeftBtn->SetPosition(25, -25);
GoLeftBtn->SetImage(GoLeftImg);
GoLeftBtn->SetSoundOver(btnSoundOver);
GoLeftBtn->SetSoundClick(btnSoundClick2);
GoLeftBtn->SetEffectGrow();
GoLeftBtn->SetTrigger(trigA);
GoLeftBtn->SetTrigger(trigL);
GoLeftBtn->SetTrigger(trigMinus);
Append(GoLeftBtn);
GoRightImg = new GuiImage(arrow_right);
GoRightBtn = new GuiButton(GoRightImg->GetWidth(), GoRightImg->GetHeight());
GoRightBtn->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
GoRightBtn->SetPosition(-25, -25);
GoRightBtn->SetImage(GoRightImg);
GoRightBtn->SetSoundOver(btnSoundOver);
GoRightBtn->SetSoundClick(btnSoundClick2);
GoRightBtn->SetEffectGrow();
GoRightBtn->SetTrigger(trigA);
GoRightBtn->SetTrigger(trigR);
GoRightBtn->SetTrigger(trigPlus);
Append(GoRightBtn);
SetupMainButtons();
AddMainButtons();
ShowButtonsEffects(EFFECT_FADE, FADE_SPEED);
}
void FlyingButtonsMenu::AddMainButtons()
{
HaltGui();
for(u32 i = 0; i < MainButton.size(); ++i)
Remove(MainButton[i]);
int FirstItem = currentPage*DISPLAY_BUTTONS;
for(int i = FirstItem; i < (int) MainButton.size() && i < FirstItem+DISPLAY_BUTTONS; ++i)
{
Append(MainButton[i]);
}
SetPageIndicators();
}
void FlyingButtonsMenu::ShowButtonsEffects(int effect, int effect_speed)
{
int FirstItem = currentPage*DISPLAY_BUTTONS;
if(FirstItem >= (int) MainButton.size())
return;
HaltGui();
for(int i = FirstItem; i < (int) MainButton.size() && i < FirstItem+DISPLAY_BUTTONS; ++i)
{
MainButton[i]->StopEffect();
MainButton[i]->SetEffect(effect, effect_speed);
}
ResumeGui();
//! Don't lock on fade in for initiation purpose
if(effect & EFFECT_FADE && effect_speed > 0)
return;
while (MainButton[FirstItem]->GetEffect() > 0)
usleep(100);
}
void FlyingButtonsMenu::SlideButtons(int direction)
{
int SlideEffectIN = 0;
if(direction == SLIDE_LEFT)
{
ShowButtonsEffects(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, SLIDE_SPEED);
SlideEffectIN = EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN;
currentPage--;
if(currentPage < 0)
currentPage = MainButton.size() > 0 ? ceil(MainButton.size()/4.0f)-1 : 0;
}
else
{
ShowButtonsEffects(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, SLIDE_SPEED);
SlideEffectIN = EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN;
currentPage++;
if(currentPage >= ceil(MainButton.size()/4.0f))
currentPage = 0;
}
AddMainButtons();
ShowButtonsEffects(SlideEffectIN, SLIDE_SPEED);
}
int FlyingButtonsMenu::MainLoop()
{
usleep(100);
if(shutdown)
Sys_Shutdown();
else if(reset)
Sys_Reboot();
if(backBtn->GetState() == STATE_CLICKED)
{
if(CurrentMenu)
{
DeleteSettingsMenu();
ShowMenu();
}
else
{
return MENU_DISCLIST;
}
backBtn->ResetState();
}
else if(GoRightBtn && GoRightBtn->GetState() == STATE_CLICKED)
{
SlideButtons(SLIDE_RIGHT);
GoRightBtn->ResetState();
}
else if(GoLeftBtn && GoLeftBtn->GetState() == STATE_CLICKED)
{
SlideButtons(SLIDE_LEFT);
GoLeftBtn->ResetState();
}
else if(homeBtn->GetState() == STATE_CLICKED)
{
Settings.Save();
if(CurrentMenu) CurrentMenu->SetState(STATE_DISABLED);
bgMusic->Pause();
int choice = WindowExitPrompt();
bgMusic->Resume();
if (choice == 3)
Sys_LoadMenu(); // Back to System Menu
else if (choice == 2)
Sys_BackToLoader();
homeBtn->ResetState();
if(CurrentMenu) CurrentMenu->SetState(STATE_DEFAULT);
}
else if(CurrentMenu)
{
int newMenu = CurrentMenu->GetMenu();
if(newMenu != MENU_NONE)
return newMenu;
}
for(u32 i = 0; i < PageIndicatorBtn.size(); ++i)
{
if(PageIndicatorBtn[i]->GetState() != STATE_CLICKED)
continue;
if(i < (u32) currentPage)
{
ShowButtonsEffects(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, SLIDE_SPEED);
currentPage = i;
AddMainButtons();
ShowButtonsEffects(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, SLIDE_SPEED);
}
else if(i > (u32) currentPage)
{
ShowButtonsEffects(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, SLIDE_SPEED);
currentPage = i;
AddMainButtons();
ShowButtonsEffects(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, SLIDE_SPEED);
}
PageIndicatorBtn[i]->ResetState();
}
for(u32 i = 0; i < MainButton.size(); ++i)
{
if(MainButton[i]->GetState() != STATE_CLICKED)
continue;
MainButton[i]->ResetState();
CreateSettingsMenu(i);
break;
}
return returnMenu;
}

View File

@ -0,0 +1,103 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef FLYINGBUTTONSMENU_HPP_
#define FLYINGBUTTONSMENU_HPP_
#include <vector>
#include <string>
#include "libwiigui/gui.h"
#include "SettingsMenu.hpp"
#include "menu.h"
class FlyingButtonsMenu : public GuiWindow
{
public:
FlyingButtonsMenu(const char * menu_title);
~FlyingButtonsMenu();
int MainLoop();
void HideMenu();
void ShowMenu();
protected:
virtual void CreateSettingsMenu(int index) { };
virtual void DeleteSettingsMenu() { };
virtual void SetupMainButtons() { };
void AddMainButtons();
void ShowButtonsEffects(int effect, int effect_speed);
void SlideButtons(int slide_direction);
void SetPageIndicators();
void SetMainButton(int position, const char * ButtonText, GuiImageData * imageData, GuiImageData * imageOver);
int currentPage;
int returnMenu;
std::string MenuTitle;
enum
{
SLIDE_LEFT, SLIDE_RIGHT
};
//!The main settings gui with browser
SettingsMenu * CurrentMenu;
GuiImageData * btnOutline;
GuiImageData * settingsbg;
GuiImageData * MainButtonImgData;
GuiImageData * MainButtonImgOverData;
GuiImageData * PageindicatorImgData;
GuiImageData * arrow_left;
GuiImageData * arrow_right;
GuiImage * settingsbackground;
GuiImage * backBtnImg;
GuiImage * PageindicatorImg2;
GuiImage * GoLeftImg;
GuiImage * GoRightImg;
GuiTrigger * trigA;
GuiTrigger * trigHome;
GuiTrigger * trigB;
GuiTrigger * trigL;
GuiTrigger * trigR;
GuiTrigger * trigMinus;
GuiTrigger * trigPlus;
GuiText * titleTxt;
GuiText * backBtnTxt;
GuiText * PageindicatorTxt1;
GuiButton * backBtn;
GuiButton * homeBtn;
GuiButton * GoLeftBtn;
GuiButton * GoRightBtn;
std::vector<GuiImage *>PageindicatorImg;
std::vector<GuiText *>PageindicatorTxt;
std::vector<GuiButton *>PageIndicatorBtn;
std::vector<GuiImage *> MainButtonImg;
std::vector<GuiImage *> MainButtonImgOver;
std::vector<GuiText *> MainButtonTxt;
std::vector<GuiButton *> MainButton;
};
#endif

View File

@ -0,0 +1,334 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include "GuiSettingsMenu.hpp"
#include "settings/CSettings.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
#include "settings/SettingsPrompts.h"
#include "settings/GameTitles.h"
#include "xml/xml.h"
#include "fatmounter.h"
static const char * OnOffText[MAX_ON_OFF] =
{
trNOOP( "OFF" ),
trNOOP( "ON" )
};
static const char * WiilightText[WIILIGHT_MAX] =
{
trNOOP( "OFF" ),
trNOOP( "ON" ),
trNOOP( "Only for Install" )
};
static const char * GameInfoText[GAMEINFO_MAX] =
{
trNOOP( "Game ID" ),
trNOOP( "Game Region" ),
trNOOP( "Both" ),
trNOOP( "Neither" )
};
static const char * FlipXText[XFLIP_MAX][3] =
{
{ trNOOP( "Right" ), "/", trNOOP( "Next" ) },
{ trNOOP( "Left" ), "/", trNOOP( "Prev" ) },
{ trNOOP( "Like SysMenu" ), "", "" },
{ trNOOP( "Right" ), "/", trNOOP( "Prev" ) },
{ trNOOP( "DiskFlip" ), "", "" }
};
static const char * PromptButtonsText[MAX_ON_OFF] =
{
trNOOP( "Normal" ),
trNOOP( "Widescreen Fix" ),
};
static const char * KeyboardText[KEYBOARD_MAX] =
{
"QWERTY",
"DVORAK",
"QWERTZ",
"AZERTY",
"QWERTY 2"
};
static const char * DiscArtDownloadText[4] =
{
trNOOP( "Only Original" ),
trNOOP( "Only Customs" ),
trNOOP( "Original/Customs" ),
trNOOP( "Customs/Original" )
};
static const char *ScreensaverText[SCREENSAVER_MAX] =
{
trNOOP( "OFF" ),
trNOOP( "3 min" ),
trNOOP( "5 min" ),
trNOOP( "10 min" ),
trNOOP( "20 min" ),
trNOOP( "30 min" ),
trNOOP( "1 hour" )
};
GuiSettingsMenu::GuiSettingsMenu()
: SettingsMenu(tr("GUI Settings"), &GuiOptions, MENU_NONE)
{
int Idx = 0;
Options->SetName(Idx++, "%s", tr( "App Language" ));
Options->SetName(Idx++, "%s", tr( "Display" ));
Options->SetName(Idx++, "%s", tr( "Clock" ));
Options->SetName(Idx++, "%s", tr( "Tooltips" ));
Options->SetName(Idx++, "%s", tr( "Flip-X" ));
Options->SetName(Idx++, "%s", tr( "Prompts Buttons" ));
Options->SetName(Idx++, "%s", tr( "Keyboard" ));
Options->SetName(Idx++, "%s", tr( "Disc Artwork Download" ));
Options->SetName(Idx++, "%s", tr( "Wiilight" ));
Options->SetName(Idx++, "%s", tr( "Rumble" ));
Options->SetName(Idx++, "%s", tr( "AutoInit Network" ));
Options->SetName(Idx++, "%s", tr( "BETA revisions" ));
Options->SetName(Idx++, "%s", tr( "Titles from WiiTDB" ));
Options->SetName(Idx++, "%s", tr( "Screensaver" ));
Options->SetName(Idx++, "%s", tr( "Mark new games" ));
SetOptionValues();
OldTitlesOverride = Settings.titlesOverride;
}
GuiSettingsMenu::~GuiSettingsMenu()
{
if (Settings.titlesOverride != OldTitlesOverride)
{
CloseXMLDatabase();
GameTitles.SetDefault();
if(Settings.titlesOverride)
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride, true);
}
}
void GuiSettingsMenu::SetOptionValues()
{
int Idx = 0;
//! Settings: App Language
const char * language = strrchr(Settings.language_path, '/');
if(language)
language += 1;
if (!language || strcmp(Settings.language_path, "") == 0)
Options->SetValue(Idx++, "%s", tr( "Default" ));
else
Options->SetValue(Idx++, "%s", language);
//! Settings: Display
Options->SetValue(Idx++, "%s", tr( GameInfoText[Settings.sinfo] ));
//! Settings: Clock
if (Settings.hddinfo == CLOCK_HR12)
Options->SetValue(Idx++, "12 %s", tr( "Hour" ));
else if (Settings.hddinfo == CLOCK_HR24)
Options->SetValue(Idx++, "24 %s", tr( "Hour" ));
else if (Settings.hddinfo == OFF)
Options->SetValue(Idx++, "%s", tr( "OFF" ));
//! Settings: Tooltips
Options->SetValue(Idx++, "%s", tr(OnOffText[Settings.tooltips]));
//! Settings: Flip-X
Options->SetValue(Idx++, "%s%s%s", tr(FlipXText[Settings.xflip][0]),
FlipXText[Settings.xflip][1], tr( FlipXText[Settings.xflip][2] ));
//! Settings: Prompts Buttons
Options->SetValue(Idx++, "%s", tr( PromptButtonsText[Settings.wsprompt] ));
//! Settings: Keyboard
Options->SetValue(Idx++, "%s", KeyboardText[Settings.keyset]);
//! Settings: Disc Artwork Download
Options->SetValue(Idx++, "%s", tr( DiscArtDownloadText[Settings.discart] ));
//! Settings: Wiilight
Options->SetValue(Idx++, "%s", tr( WiilightText[Settings.wiilight] ));
//! Settings: Rumble
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.rumble] ));
//! Settings: AutoInit Network
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.autonetwork] ));
//! Settings: BETA revisions
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.beta_upgrades] ));
//! Settings: Titles from WiiTDB
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.titlesOverride] ));
//! Settings: Screensaver
Options->SetValue(Idx++, "%s", tr( ScreensaverText[Settings.screensaver] ));
//! Settings: Mark new games
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.marknewtitles] ));
}
int GuiSettingsMenu::GetMenuInternal()
{
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: App Language
if (ret == ++Idx)
{
if (!isInserted(Settings.BootDevice))
{
WindowPrompt(tr( "No SD-Card inserted!" ), tr( "Insert an SD-Card to use this option." ), tr( "OK" ));
return MENU_NONE;
}
if (!Settings.godmode)
{
WindowPrompt(tr( "Language change:" ), tr( "Console should be unlocked to modify it." ), tr( "OK" ));
return MENU_NONE;
}
SetEffect(EFFECT_FADE, -20);
while (GetEffect() > 0) usleep(100);
HaltGui();
if(parentElement)
{
((GuiWindow *) parentElement)->Remove(this);
((GuiWindow *) parentElement)->SetState(STATE_DISABLED);
}
ResumeGui();
int returnhere = 1;
while (returnhere == 1)
returnhere = MenuLanguageSelect();
if (returnhere == 2)
return MENU_SETTINGS;
HaltGui();
if(parentElement)
{
((GuiWindow *) parentElement)->Append(this);
((GuiWindow *) parentElement)->SetState(STATE_DEFAULT);
}
SetEffect(EFFECT_FADE, 20);
ResumeGui();
while (GetEffect() > 0) usleep(100);
}
//! Settings: Display
else if (ret == ++Idx)
{
if (++Settings.sinfo >= GAMEINFO_MAX) Settings.sinfo = 0;
}
//! Settings: Clock
else if (ret == ++Idx)
{
if (++Settings.hddinfo >= CLOCK_MAX) Settings.hddinfo = 0; //CLOCK
}
//! Settings: Tooltips
else if (ret == ++Idx)
{
if (++Settings.tooltips >= MAX_ON_OFF) Settings.tooltips = 0;
}
//! Settings: Flip-X
else if (ret == ++Idx)
{
if (++Settings.xflip >= XFLIP_MAX) Settings.xflip = 0;
}
//! Settings: Prompts Buttons
else if (ret == ++Idx)
{
if (++Settings.wsprompt >= MAX_ON_OFF) Settings.wsprompt = 0;
}
//! Settings: Keyboard
else if (ret == ++Idx)
{
if (++Settings.keyset >= KEYBOARD_MAX) Settings.keyset = 0;
}
//! Settings: Disc Artwork Download
else if (ret == ++Idx)
{
if (++Settings.discart >= 4) Settings.discart = 0;
}
//! Settings: Wiilight
else if (ret == ++Idx)
{
if (++Settings.wiilight >= WIILIGHT_MAX) Settings.wiilight = 0;
}
//! Settings: Rumble
else if (ret == ++Idx)
{
if (++Settings.rumble >= MAX_ON_OFF) Settings.rumble = 0; //RUMBLE
}
//! Settings: AutoInit Network
else if (ret == ++Idx)
{
if (++Settings.autonetwork >= MAX_ON_OFF) Settings.autonetwork = 0;
}
//! Settings: BETA revisions
else if (ret == ++Idx)
{
if (++Settings.beta_upgrades >= MAX_ON_OFF) Settings.beta_upgrades = 0;
}
//! Settings: Titles from WiiTDB
else if (ret == ++Idx)
{
if (++Settings.titlesOverride >= MAX_ON_OFF) Settings.titlesOverride = 0;
}
//! Settings: Screensaver
else if (ret == ++Idx)
{
if (++Settings.screensaver >= SCREENSAVER_MAX) Settings.screensaver = 0;
}
//! Settings: Mark new games
else if (ret == ++Idx)
{
if (++Settings.marknewtitles >= MAX_ON_OFF) Settings.marknewtitles = 0;
}
SetOptionValues();
return MENU_NONE;
}

View File

@ -0,0 +1,45 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef GUISETTINGS_MENU_HPP_
#define GUISETTINGS_MENU_HPP_
#include "SettingsMenu.hpp"
class GuiSettingsMenu : public SettingsMenu
{
public:
GuiSettingsMenu();
~GuiSettingsMenu();
virtual int GetType() { return CGUISettingsMenu; };
protected:
void SetOptionValues();
int GetMenuInternal();
int OldTitlesOverride;
OptionList GuiOptions;
};
#endif

View File

@ -0,0 +1,327 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include "GameLoadSM.hpp"
#include "settings/CSettings.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
#include "wad/nandtitle.h"
#include "prompts/TitleBrowser.h"
#include "usbloader/GameList.h"
#include "usbloader/wbfs.h"
#include "usbloader/utils.h"
#include "system/IosLoader.h"
#include "settings/GameTitles.h"
#include "xml/xml.h"
#include "menu.h"
extern PartList partitions;
extern char game_partition[6];
extern u8 load_from_fs;
static const char * OnOffText[MAX_ON_OFF] =
{
trNOOP( "OFF" ),
trNOOP( "ON" )
};
static const char * VideoModeText[VIDEO_MODE_MAX] =
{
trNOOP( "Disc Default" ),
trNOOP( "System Default" ),
trNOOP( "AutoPatch" ),
trNOOP( "Force PAL50" ),
trNOOP( "Force PAL60" ),
trNOOP( "Force NTSC" )
};
static const char * LanguageText[MAX_LANGUAGE] =
{
trNOOP( "Disc Default" ),
trNOOP( "Console Default" ),
trNOOP( "Japanese" ),
trNOOP( "English" ),
trNOOP( "German" ),
trNOOP( "French" ),
trNOOP( "Spanish" ),
trNOOP( "Italian" ),
trNOOP( "Dutch" ),
trNOOP( "SChinese" ),
trNOOP( "TChinese" ),
trNOOP( "Korean" )
};
static const char * InstallToText[INSTALL_TO_MAX] =
{
trNOOP( "None" ),
trNOOP( "GAMEID_Gamename" ),
trNOOP( "Gamename [GAMEID]" )
};
static const char * Error002Text[3] =
{
trNOOP( "No" ),
trNOOP( "Yes" ),
trNOOP( "Anti" )
};
static const char * InstPartitionsText[3] =
{
trNOOP( "Game partition" ),
trNOOP( "All partitions" ),
trNOOP( "Remove update" )
};
static inline bool IsValidPartition(int fs_type, int cios)
{
if (IosLoader::IsWaninkokoIOS() && NandTitles.VersionOf(TITLE_ID(1, cios)) < 18)
{
return fs_type == FS_TYPE_WBFS;
}
else
{
return fs_type == FS_TYPE_WBFS || fs_type == FS_TYPE_FAT32 || fs_type == FS_TYPE_NTFS;
}
}
GameLoadSM::GameLoadSM()
: SettingsMenu(tr("Game Load"), &GuiOptions, MENU_NONE)
{
int Idx = 0;
Options->SetName(Idx++, "%s", tr( "Video Mode" ));
Options->SetName(Idx++, "%s", tr( "VIDTV Patch" ));
Options->SetName(Idx++, "%s", tr( "Game Language" ));
Options->SetName(Idx++, "%s", tr( "Patch Country Strings" ));
Options->SetName(Idx++, "%s", tr( "Ocarina" ));
Options->SetName(Idx++, "%s", tr( "Boot/Standard" ));
Options->SetName(Idx++, "%s", tr( "Partition" ));
Options->SetName(Idx++, "%s", tr( "FAT: Use directories" ));
Options->SetName(Idx++, "%s", tr( "Quick Boot" ));
Options->SetName(Idx++, "%s", tr( "Error 002 fix" ));
Options->SetName(Idx++, "%s", tr( "Install partitions" ));
Options->SetName(Idx++, "%s", tr( "Install 1:1 Copy" ));
Options->SetName(Idx++, "%s", tr( "Return To" ));
SetOptionValues();
OldSettingsPartition = Settings.partition;
}
GameLoadSM::~GameLoadSM()
{
// if partition has changed, Reinitialize it
if (Settings.partition != OldSettingsPartition)
{
PartInfo pinfo = partitions.pinfo[Settings.partition];
partitionEntry pentry = partitions.pentry[Settings.partition];
WBFS_OpenPart(pinfo.part_fs, pinfo.index, pentry.sector, pentry.size, (char *) &game_partition);
load_from_fs = pinfo.part_fs;
CloseXMLDatabase();
GameTitles.SetDefault();
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride, true);
gameList.ReadGameList();
}
}
void GameLoadSM::SetOptionValues()
{
int Idx = 0;
//! Settings: Video Mode
Options->SetValue(Idx++, "%s", tr(VideoModeText[Settings.videomode]));
//! Settings: VIDTV Patch
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.videopatch] ));
//! Settings: Game Language
Options->SetValue(Idx++, "%s", tr( LanguageText[Settings.language] ));
//! Settings: Patch Country Strings
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.patchcountrystrings] ));
//! Settings: Ocarina
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.ocarina] ));
//! Settings: Boot/Standard
if (Settings.godmode)
Options->SetValue(Idx++, "IOS %i", Settings.cios);
else
Options->SetValue(Idx++, "********");
//! Settings: Partition
PartInfo pInfo = partitions.pinfo[Settings.partition];
f32 partition_size = partitions.pentry[Settings.partition].size
* (partitions.sector_size / GB_SIZE);
// Get the partition name and it's size in GB's
Options->SetValue(Idx++, "%s%d (%.2fGB)", pInfo.fs_type == FS_TYPE_FAT32 ? "FAT"
: pInfo.fs_type == FS_TYPE_NTFS ? "NTFS" : "WBFS", pInfo.index, partition_size);
//! Settings: FAT: Use directories
Options->SetValue(Idx++, "%s", tr( InstallToText[Settings.FatInstallToDir] ));
//! Settings: Quick Boot
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.quickboot] ));
//! Settings: Error 002 fix
Options->SetValue(Idx++, "%s", tr( Error002Text[Settings.error002] ));
//! Settings: Install partitions
Options->SetValue(Idx++, "%s", tr( InstPartitionsText[Settings.InstallPartitions] ));
//! Settings: Install 1:1 Copy
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.fullcopy] ));
//! Settings: Return To
const char* TitleName = NULL;
int haveTitle = NandTitles.FindU32(Settings.returnTo);
if (haveTitle >= 0)
TitleName = NandTitles.NameFromIndex(haveTitle);
Options->SetValue(Idx++, "%s", TitleName ? TitleName : strlen(Settings.returnTo) > 0 ?
Settings.returnTo : tr( OnOffText[0] ));
}
int GameLoadSM::GetMenuInternal()
{
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: Video Mode
if (ret == ++Idx)
{
if (++Settings.videomode >= VIDEO_MODE_MAX) Settings.videomode = 0;
}
//! Settings: VIDTV Patch
else if (ret == ++Idx)
{
if (++Settings.videopatch >= MAX_ON_OFF) Settings.videopatch = 0;
}
//! Settings: Game Language
else if (ret == ++Idx)
{
if (++Settings.language >= MAX_LANGUAGE) Settings.language = 0;
}
//! Settings: Patch Country Strings
else if (ret == ++Idx)
{
if (++Settings.patchcountrystrings >= MAX_ON_OFF) Settings.patchcountrystrings = 0;
}
//! Settings: Ocarina
else if (ret == ++Idx)
{
if (++Settings.ocarina >= MAX_ON_OFF) Settings.ocarina = 0;
}
//! Settings: Boot/Standard
else if (ret == ++Idx)
{
if(!Settings.godmode)
return MENU_NONE;
char entered[4];
snprintf(entered, sizeof(entered), "%i", Settings.cios);
if(OnScreenKeyboard(entered, sizeof(entered), 0))
{
Settings.cios = atoi(entered);
if(Settings.cios < 200) Settings.cios = 200;
else if(Settings.cios > 255) Settings.cios = 255;
if(NandTitles.IndexOf(TITLE_ID(1, Settings.cios)) < 0)
{
WindowPrompt(tr("Warning:"), tr("This IOS was not found on the titles list. If you are sure you have it installed than ignore this warning."), tr("OK"));
}
else if(Settings.cios == 254)
{
WindowPrompt(tr("Warning:"), tr("This IOS is the BootMii ios. If you are sure it is not BootMii and you have something else installed there than ignore this warning."), tr("OK"));
}
}
}
//! Settings: Partition
else if (ret == ++Idx)
{
// Select the next valid partition, even if that's the same one
int fs_type = partitions.pinfo[Settings.partition].fs_type;
int ios = IOS_GetVersion();
do
{
Settings.partition = (Settings.partition + 1) % partitions.num;
fs_type = partitions.pinfo[Settings.partition].fs_type;
}
while (!IsValidPartition(fs_type, ios));
}
//! Settings: FAT: Use directories
else if (ret == ++Idx)
{
if (++Settings.FatInstallToDir >= INSTALL_TO_MAX) Settings.FatInstallToDir = 0;
}
//! Settings: Quick Boot
else if (ret == ++Idx)
{
if (++Settings.quickboot >= MAX_ON_OFF) Settings.quickboot = 0;
}
//! Settings: Error 002 fix
else if (ret == ++Idx )
{
if (++Settings.error002 >= 3) Settings.error002 = 0;
}
//! Settings: Install partitions
else if (ret == ++Idx)
{
if (++Settings.InstallPartitions >= 3) Settings.InstallPartitions = 0;
}
//! Settings: Install 1:1 Copy
else if (ret == ++Idx)
{
if (++Settings.fullcopy >= MAX_ON_OFF) Settings.fullcopy = 0;
}
//! Settings: Return To
else if (ret == ++Idx)
{
char tidChar[10];
bool getChannel = TitleSelector(tidChar);
if (getChannel)
snprintf(Settings.returnTo, sizeof(Settings.returnTo), "%s", tidChar);
}
SetOptionValues();
return MENU_NONE;
}

View File

@ -0,0 +1,45 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef GAMELOADSM_HPP_
#define GAMELOADSM_HPP_
#include "SettingsMenu.hpp"
class GameLoadSM : public SettingsMenu
{
public:
GameLoadSM();
~GameLoadSM();
virtual int GetType() { return CGameLoadSM; };
protected:
void SetOptionValues();
int GetMenuInternal();
int OldSettingsPartition;
OptionList GuiOptions;
};
#endif

View File

@ -0,0 +1,121 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include "GameSettingsMenu.hpp"
#include "themes/CTheme.h"
#include "prompts/PromptWindows.h"
#include "settings/GameTitles.h"
#include "language/gettext.h"
#include "wad/nandtitle.h"
#include "cheats/cheatmenu.h"
#include "IndGameLoadSM.hpp"
#include "UninstallSM.hpp"
GameSettingsMenu::GameSettingsMenu(struct discHdr * header)
: FlyingButtonsMenu(GameTitles.GetTitle(header))
{
DiscHeader = header;
}
GameSettingsMenu::~GameSettingsMenu()
{
}
void GameSettingsMenu::SetupMainButtons()
{
int pos = 0;
SetMainButton(pos++, tr( "Game Load" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Ocarina" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Uninstall Menu" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Default Gamesettings" ), MainButtonImgData, MainButtonImgOverData);
}
void GameSettingsMenu::CreateSettingsMenu(int menuNr)
{
if(CurrentMenu)
return;
int Idx = 0;
//! Game Load
if(menuNr == Idx++)
{
HideMenu();
ResumeGui();
CurrentMenu = new IndGameLoadSM((const char *) DiscHeader->id);
Append(CurrentMenu);
}
//! Ocarina
else if(menuNr == Idx++)
{
char ID[7];
snprintf(ID, sizeof(ID), "%s", (char *) DiscHeader->id);
CheatMenu(ID);
}
//! Uninstall Menu
else if(menuNr == Idx++)
{
HideMenu();
ResumeGui();
CurrentMenu = new UninstallSM(DiscHeader);
Append(CurrentMenu);
}
//! Default Gamesettings
else if(menuNr == Idx++)
{
int choice = WindowPrompt(tr( "Are you sure?" ), 0, tr( "Yes" ), tr( "Cancel" ));
if (choice == 1)
{
GameSettings.Remove(DiscHeader->id);
GameSettings.Save();
}
}
}
void GameSettingsMenu::DeleteSettingsMenu()
{
if(!CurrentMenu)
return;
int type = CurrentMenu->GetType();
switch(type)
{
case CIndGameLoadSM:
delete ((IndGameLoadSM *) CurrentMenu);
break;
case CUninstallSM:
delete ((UninstallSM *) CurrentMenu);
break;
case CSettingsMenu:
default:
delete CurrentMenu;
break;
}
CurrentMenu = NULL;
}

View File

@ -0,0 +1,44 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef GAMESETTINGSMENU_HPP_
#define GAMESETTINGSMENU_HPP_
#include "FlyingButtonsMenu.hpp"
#include "settings/CGameSettings.h"
#include "usbloader/disc.h"
class GameSettingsMenu : public FlyingButtonsMenu
{
public:
GameSettingsMenu(struct discHdr * header);
~GameSettingsMenu();
protected:
virtual void CreateSettingsMenu(int index);
virtual void DeleteSettingsMenu();
virtual void SetupMainButtons();
struct discHdr * DiscHeader;
};
#endif

View File

@ -0,0 +1,200 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include "GlobalSettings.hpp"
#include "themes/CTheme.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
#include "GuiSettingsMenu.hpp"
#include "GameLoadSM.hpp"
#include "ParentalControlSM.hpp"
#include "SoundSettingsMenu.hpp"
#include "CustomPathsSM.hpp"
GlobalSettings::GlobalSettings()
: FlyingButtonsMenu(tr("Global Settings"))
{
creditsImgData = Resources::GetImageData("credits_button.png");
creditsImgOverData = Resources::GetImageData("credits_button_over.png");
}
GlobalSettings::~GlobalSettings()
{
Settings.Save();
delete creditsImgData;
delete creditsImgOverData;
}
void GlobalSettings::SetupMainButtons()
{
int pos = 0;
SetMainButton(pos++, tr( "GUI Settings" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Game Load" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Parental Control" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Sound" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Custom Paths" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Update" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Default Settings" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Credits" ), creditsImgData, creditsImgOverData);
SetMainButton(pos++, tr( "Theme Downloader" ), MainButtonImgData, MainButtonImgOverData);
}
void GlobalSettings::CreateSettingsMenu(int menuNr)
{
if(CurrentMenu)
return;
int Idx = 0;
//! GUI Settings
if(menuNr == Idx++)
{
HideMenu();
ResumeGui();
CurrentMenu = new GuiSettingsMenu();
Append(CurrentMenu);
}
//! Game Load
else if(menuNr == Idx++)
{
HideMenu();
ResumeGui();
CurrentMenu = new GameLoadSM();
Append(CurrentMenu);
}
//! Parental Control
else if(menuNr == Idx++)
{
HideMenu();
ResumeGui();
CurrentMenu = new ParentalControlSM();
Append(CurrentMenu);
}
//! Sound
else if(menuNr == Idx++)
{
HideMenu();
ResumeGui();
CurrentMenu = new SoundSettingsMenu();
Append(CurrentMenu);
}
//! Custom Paths
else if(menuNr == Idx++)
{
if(Settings.godmode)
{
HideMenu();
ResumeGui();
CurrentMenu = new CustomPathsSM();
Append(CurrentMenu);
}
else
WindowPrompt(tr( "Console Locked" ), tr( "Unlock console to use this option." ), tr( "OK" ));
}
//! Update
else if(menuNr == Idx++)
{
if (Settings.godmode)
{
HideMenu();
Remove(backBtn);
ResumeGui();
int ret = ProgressUpdateWindow();
if (ret < 0)
WindowPrompt(tr( "Update failed" ), 0, tr( "OK" ));
Append(backBtn);
ShowMenu();
}
else
WindowPrompt(tr( "Console Locked" ), tr( "Unlock console to use this option." ), tr( "OK" ));
}
//! Default Settings
else if(menuNr == Idx++)
{
if (Settings.godmode)
{
int choice = WindowPrompt(tr( "Are you sure you want to reset?" ), 0, tr( "Yes" ), tr( "Cancel" ));
if (choice == 1)
{
HaltGui();
gettextCleanUp();
Settings.Reset();
returnMenu = MENU_SETTINGS;
ResumeGui();
}
}
else
WindowPrompt(tr( "Console Locked" ), tr( "Unlock console to use this option." ), tr( "OK" ));
}
//! Credits
else if(menuNr == Idx++)
{
HideMenu();
Remove(backBtn);
ResumeGui();
WindowCredits();
Append(backBtn);
ShowMenu();
}
//! Theme Downloader
else if(menuNr == Idx++)
{
returnMenu = MENU_THEMEDOWNLOADER;
}
}
void GlobalSettings::DeleteSettingsMenu()
{
if(!CurrentMenu)
return;
int type = CurrentMenu->GetType();
switch(type)
{
case CGUISettingsMenu:
delete ((GuiSettingsMenu *) CurrentMenu);
break;
case CGameLoadSM:
delete ((GameLoadSM *) CurrentMenu);
break;
case CParentalControlSM:
delete ((ParentalControlSM *) CurrentMenu);
break;
case CSoundSettingsMenu:
delete ((SoundSettingsMenu *) CurrentMenu);
break;
case CCustomPathsSM:
delete ((CustomPathsSM *) CurrentMenu);
break;
case CSettingsMenu:
default:
delete CurrentMenu;
break;
}
CurrentMenu = NULL;
}

View File

@ -0,0 +1,43 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef GLOBAL_SETTINGS_HPP_
#define GLOBAL_SETTINGS_HPP_
#include "FlyingButtonsMenu.hpp"
class GlobalSettings : public FlyingButtonsMenu
{
public:
GlobalSettings();
~GlobalSettings();
protected:
virtual void CreateSettingsMenu(int index);
virtual void DeleteSettingsMenu();
virtual void SetupMainButtons();
GuiImageData * creditsImgData;
GuiImageData * creditsImgOverData;
};
#endif

View File

@ -0,0 +1,409 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include <gccore.h>
#include "settings/CSettings.h"
#include "themes/CTheme.h"
#include "prompts/PromptWindows.h"
#include "prompts/DiscBrowser.h"
#include "language/gettext.h"
#include "wad/nandtitle.h"
#include "IndGameLoadSM.hpp"
static const char * OnOffText[MAX_ON_OFF] =
{
trNOOP( "OFF" ),
trNOOP( "ON" )
};
static const char * VideoModeText[VIDEO_MODE_MAX] =
{
trNOOP( "Disc Default" ),
trNOOP( "System Default" ),
trNOOP( "AutoPatch" ),
trNOOP( "Force PAL50" ),
trNOOP( "Force PAL60" ),
trNOOP( "Force NTSC" )
};
static const char * LanguageText[MAX_LANGUAGE] =
{
trNOOP( "Disc Default" ),
trNOOP( "Console Default" ),
trNOOP( "Japanese" ),
trNOOP( "English" ),
trNOOP( "German" ),
trNOOP( "French" ),
trNOOP( "Spanish" ),
trNOOP( "Italian" ),
trNOOP( "Dutch" ),
trNOOP( "SChinese" ),
trNOOP( "TChinese" ),
trNOOP( "Korean" )
};
static const char * Error002Text[3] =
{
trNOOP( "No" ),
trNOOP( "Yes" ),
trNOOP( "Anti" )
};
static const char * ParentalText[5] =
{
trNOOP( "0 (Everyone)" ),
trNOOP( "1 (Child 7+)" ),
trNOOP( "2 (Teen 12+)" ),
trNOOP( "3 (Mature 16+)" ),
trNOOP( "4 (Adults Only 18+)" )
};
static const char * AlternateDOLText[] =
{
trNOOP( "OFF" ),
trNOOP( "Load From SD/USB" ),
trNOOP( "Select a DOL" )
};
IndGameLoadSM::IndGameLoadSM(const char * GameID)
: SettingsMenu(tr("Game Load"), &GuiOptions, MENU_NONE)
{
//! Setup default settings from global settings
snprintf(GameConfig.id, sizeof(GameConfig.id), "%s", (char *) GameID);
SetDefaultConfig();
GameCFG * existCFG = GameSettings.GetGameCFG(GameID);
//! Overwrite with existing if available
if (existCFG)
memcpy(&GameConfig, existCFG, sizeof(GameCFG));
if(!btnOutline)
btnOutline = Resources::GetImageData("button_dialogue_box.png");
if(!trigA)
trigA = new GuiTrigger();
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
saveBtnTxt = new GuiText(tr( "Save" ), 22, Theme.prompttext);
saveBtnTxt->SetMaxWidth(btnOutline->GetWidth() - 30);
saveBtnImg = new GuiImage (btnOutline);
if (Settings.wsprompt == ON)
{
saveBtnTxt->SetWidescreen(Settings.widescreen);
saveBtnImg->SetWidescreen(Settings.widescreen);
}
saveBtn = new GuiButton(saveBtnImg, saveBtnImg, 2, 3, 180, 400, trigA, btnSoundOver, btnSoundClick2, 1);
saveBtn->SetLabel(saveBtnTxt);
Append(saveBtn);
SetOptionNames();
SetOptionValues();
}
IndGameLoadSM::~IndGameLoadSM()
{
HaltGui();
//! The rest is destroyed in SettingsMenu.cpp
Remove(saveBtn);
delete saveBtnTxt;
delete saveBtnImg;
delete saveBtn;
ResumeGui();
}
void IndGameLoadSM::SetDefaultConfig()
{
GameConfig.video = Settings.videomode;
GameConfig.language = Settings.language;
GameConfig.ocarina = Settings.ocarina;
GameConfig.vipatch = Settings.videopatch;
GameConfig.ios = Settings.cios;
GameConfig.parentalcontrol = 0;
GameConfig.errorfix002 = Settings.error002;
GameConfig.patchcountrystrings = Settings.patchcountrystrings;
GameConfig.loadalternatedol = OFF;
GameConfig.alternatedolstart = 0;
GameConfig.iosreloadblock = OFF;
strcpy(GameConfig.alternatedolname, "");
GameConfig.returnTo = 1;
GameConfig.Locked = 0;
}
void IndGameLoadSM::SetOptionNames()
{
int Idx = 0;
Options->SetName(Idx++, "%s", tr( "Video Mode" ));
Options->SetName(Idx++, "%s", tr( "VIDTV Patch" ));
Options->SetName(Idx++, "%s", tr( "Game Language" ));
Options->SetName(Idx++, "%s", tr( "Patch Country Strings" ));
Options->SetName(Idx++, "%s", tr( "Ocarina" ));
Options->SetName(Idx++, "%s", tr( "Game IOS" ));
Options->SetName(Idx++, "%s", tr( "Parental Control" ));
Options->SetName(Idx++, "%s", tr( "Error 002 fix" ));
Options->SetName(Idx++, "%s", tr( "Return To" ));
Options->SetName(Idx++, "%s", tr( "Alternate DOL" ));
Options->SetName(Idx++, "%s", tr( "Select DOL Offset" ));
Options->SetName(Idx++, "%s", tr( "Block IOS Reload" ));
Options->SetName(Idx++, "%s", tr( "Game Lock" ));
}
void IndGameLoadSM::SetOptionValues()
{
int Idx = 0;
//! Settings: Video Mode
Options->SetValue(Idx++, "%s", tr(VideoModeText[GameConfig.video]));
//! Settings: VIDTV Patch
Options->SetValue(Idx++, "%s", tr(OnOffText[GameConfig.vipatch]));
//! Settings: Game Language
Options->SetValue(Idx++, "%s", tr(LanguageText[GameConfig.language]));
//! Settings: Patch Country Strings
Options->SetValue(Idx++, "%s", tr(OnOffText[GameConfig.patchcountrystrings]));
//! Settings: Ocarina
Options->SetValue(Idx++, "%s", tr(OnOffText[GameConfig.ocarina]));
//! Settings: Game IOS
Options->SetValue(Idx++, "%i", GameConfig.ios);
//! Settings: Parental Control
Options->SetValue(Idx++, "%s", tr(ParentalText[GameConfig.parentalcontrol]));
//! Settings: Error 002 fix
Options->SetValue(Idx++, "%s", tr(Error002Text[GameConfig.errorfix002]));
//! Settings: Return To
if(GameConfig.returnTo)
{
const char* TitleName = NULL;
int haveTitle = NandTitles.FindU32(Settings.returnTo);
if (haveTitle >= 0)
TitleName = NandTitles.NameFromIndex(haveTitle);
Options->SetValue(Idx++, "%s", TitleName ? TitleName : strlen(Settings.returnTo) > 0 ?
Settings.returnTo : tr( OnOffText[0] ));
}
else
{
Options->SetValue(Idx++, "%s", tr( OnOffText[0] ));
}
//! Settings: Alternate DOL
Options->SetValue(Idx++, "%s", tr( AlternateDOLText[GameConfig.loadalternatedol] ));
//! Settings: Select DOL Offset
if(GameConfig.loadalternatedol != 2)
Options->SetValue(Idx++, tr("Not required"));
else
{
if(strcmp(GameConfig.alternatedolname, "") != 0)
Options->SetValue(Idx++, "%i <%s>", GameConfig.alternatedolstart, GameConfig.alternatedolname);
else
Options->SetValue(Idx++, "%i", GameConfig.alternatedolstart);
}
//! Settings: Block IOS Reload
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.iosreloadblock] ));
//! Settings: Game Lock
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.Locked] ));
}
int IndGameLoadSM::GetMenuInternal()
{
if (saveBtn->GetState() == STATE_CLICKED)
{
if (GameSettings.AddGame(GameConfig) && GameSettings.Save())
{
WindowPrompt(tr( "Successfully Saved" ), 0, tr( "OK" ));
}
else
WindowPrompt(tr( "Save Failed. No device inserted?" ), 0, tr( "OK" ));
saveBtn->ResetState();
}
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: Video Mode
if (ret == ++Idx)
{
if (++GameConfig.video >= VIDEO_MODE_MAX) GameConfig.video = 0;
}
//! Settings: VIDTV Patch
else if (ret == ++Idx)
{
if (++GameConfig.vipatch >= MAX_ON_OFF) GameConfig.vipatch = 0;
}
//! Settings: Game Language
else if (ret == ++Idx)
{
if (++GameConfig.language >= MAX_LANGUAGE) GameConfig.language = 0;
}
//! Settings: Patch Country Strings
else if (ret == ++Idx)
{
if (++GameConfig.patchcountrystrings >= MAX_ON_OFF) GameConfig.patchcountrystrings = 0;
}
//! Settings: Ocarina
else if (ret == ++Idx)
{
if (++GameConfig.ocarina >= MAX_ON_OFF) GameConfig.ocarina = 0;
}
//! Settings: Game IOS
else if (ret == ++Idx)
{
char entered[4];
snprintf(entered, sizeof(entered), "%i", GameConfig.ios);
if(OnScreenKeyboard(entered, sizeof(entered), 0))
{
GameConfig.ios = atoi(entered);
if(GameConfig.ios < 200) GameConfig.ios = 200;
else if(GameConfig.ios > 255) GameConfig.ios = 255;
if(NandTitles.IndexOf(TITLE_ID(1, GameConfig.ios)) < 0)
{
WindowPrompt(tr("Warning:"), tr("This IOS was not found on the titles list. If you are sure you have it installed than ignore this warning."), tr("OK"));
}
else if(GameConfig.ios == 254)
{
WindowPrompt(tr("Warning:"), tr("This IOS is the BootMii ios. If you are sure it is not BootMii and you have something else installed there than ignore this warning."), tr("OK"));
}
}
}
//! Settings: Parental Control
else if (ret == ++Idx)
{
if (++GameConfig.parentalcontrol >= 5) GameConfig.parentalcontrol = 0;
}
//! Settings: Error 002 fix
else if (ret == ++Idx)
{
if (++GameConfig.errorfix002 >= 3) GameConfig.errorfix002 = 0;
}
//! Settings: Return To
else if (ret == ++Idx)
{
if (++GameConfig.returnTo >= MAX_ON_OFF) GameConfig.returnTo = 0;
}
//! Settings: Alternate DOL
else if (ret == ++Idx)
{
if (--GameConfig.loadalternatedol < 0) // 0->2->1->0
GameConfig.loadalternatedol = 2;
}
//! Settings: Select DOL Offset
else if (ret == ++Idx && GameConfig.loadalternatedol == 2)
{
char filename[10];
snprintf(filename, 7, "%s", GameConfig.id);
//alt dol menu for games that require more than a single alt dol
int autodol = autoSelectDolMenu(filename, false);
if (autodol > 0)
{
GameConfig.alternatedolstart = autodol;
snprintf(GameConfig.alternatedolname, sizeof(GameConfig.alternatedolname), "%s <%i>", tr( "AUTO" ), autodol);
SetOptionValues();
return MENU_NONE;
}
else if (autodol == 0)
{
GameConfig.loadalternatedol = 0;
SetOptionValues();
return MENU_NONE;
}
//check to see if we already know the offset of the correct dol
autodol = autoSelectDol(filename, false);
//if we do know that offset ask if they want to use it
if (autodol > 0)
{
int dolchoice = WindowPrompt(0, tr( "Do you want to use the alternate DOL that is known to be correct?" ),
tr( "Yes" ), tr( "Pick from a list" ), tr( "Cancel" ));
if (dolchoice == 1)
{
GameConfig.alternatedolstart = autodol;
snprintf(GameConfig.alternatedolname, sizeof(GameConfig.alternatedolname), "%s <%i>", tr( "AUTO" ), autodol);
}
else if (dolchoice == 2) //they want to search for the correct dol themselves
{
int res = DiscBrowse(GameConfig.id, GameConfig.alternatedolname, sizeof(GameConfig.alternatedolname));
if ((res >= 0) && (res != 696969)) //if res==696969 they pressed the back button
GameConfig.alternatedolstart = res;
}
}
else
{
int res = DiscBrowse(GameConfig.id, GameConfig.alternatedolname, sizeof(GameConfig.alternatedolname));
if ((res >= 0) && (res != 696969))
{
GameConfig.alternatedolstart = res;
char tmp[170];
snprintf(tmp, sizeof(tmp), "%s %s - %i", tr( "It seems that you have some information that will be helpful to us. Please pass this information along to the DEV team." ),
filename, GameConfig.alternatedolstart);
WindowPrompt(0, tmp, tr( "OK" ));
}
}
if(GameConfig.alternatedolstart == 0)
GameConfig.loadalternatedol = 0;
}
//! Settings: Block IOS Reload
else if (ret == ++Idx)
{
if (++GameConfig.iosreloadblock >= MAX_ON_OFF) GameConfig.iosreloadblock = 0;
}
//! Settings: Game Lock
else if (ret == ++Idx)
{
if (++GameConfig.Locked >= MAX_ON_OFF) GameConfig.Locked = 0;
}
SetOptionValues();
return MENU_NONE;
}

View File

@ -0,0 +1,51 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef INDIVIDUAL_GAMELOAD_SM_HPP
#define INDIVIDUAL_GAMELOAD_SM_HPP
#include "SettingsMenu.hpp"
#include "settings/CGameSettings.h"
class IndGameLoadSM : public SettingsMenu
{
public:
IndGameLoadSM(const char * GameID);
~IndGameLoadSM();
virtual int GetType() { return CIndGameLoadSM; };
protected:
void SetDefaultConfig();
void SetOptionNames();
void SetOptionValues();
int GetMenuInternal();
GameCFG GameConfig;
OptionList GuiOptions;
GuiText * saveBtnTxt;
GuiImage * saveBtnImg;
GuiButton * saveBtn;
};
#endif

View File

@ -0,0 +1,181 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include "ParentalControlSM.hpp"
#include "settings/CSettings.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
static const char * LockModeText[] =
{
trNOOP( "Locked" ),
trNOOP( "Unlocked" )
};
static const char * ParentalText[5] =
{
trNOOP( "0 (Everyone)" ),
trNOOP( "1 (Child 7+)" ),
trNOOP( "2 (Teen 12+)" ),
trNOOP( "3 (Mature 16+)" ),
trNOOP( "4 (Adults Only 18+)" )
};
static const char * LockedGamesText[2] =
{
trNOOP( "0 (Locked and Unlocked Games)" ),
trNOOP( "1 (Unlocked Games Only)" )
};
ParentalControlSM::ParentalControlSM()
: SettingsMenu(tr("Parental Control"), &GuiOptions, MENU_NONE)
{
int Idx = 0;
Options->SetName(Idx++, "%s", tr( "Console" ));
Options->SetName(Idx++, "%s", tr( "Password" ));
Options->SetName(Idx++, "%s", tr( "Controllevel" ));
Options->SetName(Idx++, "%s", tr( "GamesLevel" ));
SetOptionValues();
}
void ParentalControlSM::SetOptionValues()
{
int Idx = 0;
//! Settings: Console
Options->SetValue(Idx++, "%s", tr( LockModeText[Settings.godmode] ));
//! Settings: Password
if (!Settings.godmode)
Options->SetValue(Idx++, "********");
else if (strcmp(Settings.unlockCode, "") == 0)
Options->SetValue(Idx++, "%s", tr( "not set" ));
else
Options->SetValue(Idx++, Settings.unlockCode);
//! Settings: Controllevel
if (Settings.godmode)
Options->SetValue(Idx++, "%s", tr( ParentalText[Settings.parentalcontrol] ));
else
Options->SetValue(Idx++, "********");
//! Settings: GamesLevel
if (Settings.godmode)
Options->SetValue(Idx++, "%s", tr( LockedGamesText[Settings.lockedgames] ));
else
Options->SetValue(Idx++, "********");
}
int ParentalControlSM::GetMenuInternal()
{
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: Console
if (ret == ++Idx)
{
if (strcmp(Settings.unlockCode, "") == 0 && !Settings.Parental.enabled)
{
Settings.godmode = !Settings.godmode;
}
else if (!Settings.godmode)
{
char entered[20];
memset(entered, 0, 20);
//password check to unlock Install,Delete and Format
SetState(STATE_DISABLED);
int result = Settings.Parental.enabled == 0 ? OnScreenKeyboard(entered, 20, 0) : OnScreenNumpad(entered, 5);
SetState(STATE_DEFAULT);
if (result == 1)
{
if (strcmp(entered, Settings.unlockCode) == 0 || !memcmp(entered, Settings.Parental.pin, 4)) //if password correct
{
WindowPrompt(
tr( "Correct Password" ),
tr( "All the features of USB Loader GX are unlocked." ),
tr( "OK" ));
Settings.godmode = 1;
}
else
WindowPrompt(tr( "Wrong Password" ), tr( "USB Loader GX is protected" ), tr( "OK" ));
}
}
else
{
int choice = WindowPrompt(tr( "Lock Console" ), tr( "Are you sure?" ),
tr( "Yes" ), tr( "No" ));
if (choice == 1)
{
WindowPrompt(tr( "Console Locked" ), tr( "USB Loader GX is protected" ),
tr( "OK" ));
Settings.godmode = 0;
}
}
}
//! Settings: Password
else if (ret == ++Idx)
{
if (Settings.godmode)
{
char entered[20];
SetState(STATE_DISABLED);
snprintf(entered, sizeof(entered), Settings.unlockCode);
int result = OnScreenKeyboard(entered, 20, 0);
SetState(STATE_DEFAULT);
if (result == 1)
{
snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), entered);
WindowPrompt(tr( "Password Changed" ), tr( "Password has been changed" ), tr( "OK" ));
}
}
else
{
WindowPrompt(tr( "Password Changed" ), tr( "Console should be unlocked to modify it." ), tr( "OK" ));
}
}
//! Settings: Controllevel
else if (ret == ++Idx)
{
if (Settings.godmode && ++Settings.parentalcontrol >= 5) Settings.parentalcontrol = 0;
}
//! Settings: GamesLevel
else if (ret == ++Idx)
{
if (Settings.godmode && ++Settings.lockedgames >= 2) Settings.lockedgames = 0;
}
SetOptionValues();
return MENU_NONE;
}

View File

@ -0,0 +1,42 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef PARENTALCONTROL_MENU_HPP_
#define PARENTALCONTROL_MENU_HPP_
#include "SettingsMenu.hpp"
class ParentalControlSM : public SettingsMenu
{
public:
ParentalControlSM();
virtual int GetType() { return CParentalControlSM; };
protected:
void SetOptionValues();
int GetMenuInternal();
OptionList GuiOptions;
};
#endif

View File

@ -0,0 +1,125 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include "SettingsMenu.hpp"
#include "themes/CTheme.h"
#include "language/gettext.h"
SettingsMenu::SettingsMenu(const char * title, OptionList * opts, int returnTo)
: GuiWindow(screenwidth, screenheight)
{
Options = opts;
returnToMenu = returnTo;
backBtn = NULL;
trigA = NULL;
trigB = NULL;
backBtnTxt = NULL;
backBtnImg = NULL;
backBtn = NULL;
btnOutline = NULL;
//! Skipping back button if there is no menu defined to go back to
if(returnToMenu != MENU_NONE)
{
btnOutline = Resources::GetImageData("button_dialogue_box.png");
trigA = new GuiTrigger();
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger();
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
backBtnTxt = new GuiText(tr("Back"), 22, (GXColor){0, 0, 0, 255});
backBtnImg = new GuiImage(btnOutline);
backBtn = new GuiButton(backBtnImg, backBtnImg, 2, 3, -180, 400, trigA, btnSoundOver, btnSoundClick2, 1);
backBtn->SetLabel(backBtnTxt);
backBtn->SetTrigger(trigB);
Append(backBtn);
}
optionBrowser = new GuiCustomOptionBrowser(396, 280, Options, "bg_options_settings.png", 0, 150);
optionBrowser->SetPosition(0, 90);
optionBrowser->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt = new GuiText(title, 28, (GXColor) {0, 0, 0, 255});
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(0, 40);
Append(optionBrowser);
Append(titleTxt);
SetEffect(EFFECT_FADE, 50);
}
SettingsMenu::~SettingsMenu()
{
ResumeGui();
SetEffect(EFFECT_FADE, -50);
while(this->GetEffect() > 0)
usleep(100);
HaltGui();
if(parentElement)
((GuiWindow *) parentElement)->Remove(this);
RemoveAll();
if(btnOutline)
delete btnOutline;
if(backBtnTxt)
delete backBtnTxt;
if(backBtnImg)
delete backBtnImg;
if(backBtn)
delete backBtn;
if(trigA)
delete trigA;
if(trigB)
delete trigB;
delete titleTxt;
delete optionBrowser;
ResumeGui();
}
int SettingsMenu::GetClickedOption()
{
if(!optionBrowser)
return -1;
return optionBrowser->GetClickedOption();
}
int SettingsMenu::GetMenu()
{
if(backBtn && backBtn->GetState() == STATE_CLICKED)
return returnToMenu;
return GetMenuInternal();
}

View File

@ -0,0 +1,72 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef SETTINGS_MENU_HPP_
#define SETTINGS_MENU_HPP_
#include "libwiigui/gui.h"
#include "libwiigui/gui_customoptionbrowser.h"
#include "menu.h"
enum
{
CSettingsMenu = 0,
CGUISettingsMenu,
CGameLoadSM,
CParentalControlSM,
CSoundSettingsMenu,
CCustomPathsSM,
CIndGameLoadSM,
CUninstallSM,
};
class SettingsMenu : public GuiWindow
{
public:
SettingsMenu(const char * title, OptionList * option, int returnTo);
~SettingsMenu();
int GetClickedOption();
int GetMenu();
virtual int GetType() { return CSettingsMenu; }
protected:
virtual int GetMenuInternal() { return MENU_NONE; };
int returnToMenu;
GuiImageData * btnOutline;
GuiTrigger * trigA;
GuiTrigger * trigB;
OptionList * Options;
GuiText * titleTxt;
GuiText * backBtnTxt;
GuiImage * backBtnImg;
GuiButton * backBtn;
GuiCustomOptionBrowser * optionBrowser;
};
#endif

View File

@ -0,0 +1,180 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include "SoundSettingsMenu.hpp"
#include "settings/CSettings.h"
#include "settings/SettingsPrompts.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
static const char * GameSoundText[] =
{
trNOOP( "Sound+Quiet" ),
trNOOP( "Sound+BGM" ),
trNOOP( "Loop Sound" ),
};
static const char * MusicLoopText[] =
{
trNOOP( "Play Once" ),
trNOOP( "Loop Music" ),
trNOOP( "Random Directory Music" ),
trNOOP( "Loop Directory" ),
};
SoundSettingsMenu::SoundSettingsMenu()
: SettingsMenu(tr("Sound Settings"), &GuiOptions, MENU_NONE)
{
int Idx = 0;
Options->SetName(Idx++, "%s", tr( "Backgroundmusic" ));
Options->SetName(Idx++, "%s", tr( "Music Volume" ));
Options->SetName(Idx++, "%s", tr( "SFX Volume" ));
Options->SetName(Idx++, "%s", tr( "Game Sound Mode" ));
Options->SetName(Idx++, "%s", tr( "Game Sound Volume" ));
Options->SetName(Idx++, "%s", tr( "Music Loop Mode" ));
Options->SetName(Idx++, "%s", tr( "Reset BG Music" ));
SetOptionValues();
}
void SoundSettingsMenu::SetOptionValues()
{
int Idx = 0;
//! Settings: Backgroundmusic
const char * filename = strrchr(Settings.ogg_path, '/');
if (filename)
Options->SetValue(Idx++, filename+1);
else
Options->SetValue(Idx++, tr( "Default" ));
//! Settings: Music Volume
if (Settings.volume > 0)
Options->SetValue(Idx++, "%i", Settings.volume);
else
Options->SetValue(Idx++, tr( "OFF" ));
//! Settings: SFX Volume
if (Settings.sfxvolume > 0)
Options->SetValue(Idx++, "%i", Settings.sfxvolume);
else
Options->SetValue(Idx++, tr( "OFF" ));
//! Settings: Game Sound Mode
Options->SetValue(Idx++, "%s", tr( GameSoundText[Settings.gamesound] ));
//! Settings: Game Sound Volume
if (Settings.gamesoundvolume > 0)
Options->SetValue(Idx++, "%i", Settings.gamesoundvolume);
else
Options->SetValue(Idx++, tr( "OFF" ));
//! Settings: Music Loop Mode
Options->SetValue(Idx++, tr( MusicLoopText[Settings.musicloopmode] ));
//! Settings: Reset BG Music
Options->SetValue(Idx++, " ");
}
int SoundSettingsMenu::GetMenuInternal()
{
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: Backgroundmusic
if (ret == ++Idx)
{
SetEffect(EFFECT_FADE, -20);
while (GetEffect() > 0) usleep(100);
HaltGui();
GuiWindow * parent = (GuiWindow *) parentElement;
if(parent) parent->SetState(STATE_DISABLED);
ResumeGui();
MenuBackgroundMusic();
HaltGui();
SetEffect(EFFECT_FADE, 20);
if(parent) parent->SetState(STATE_DEFAULT);
ResumeGui();
while (GetEffect() > 0) usleep(100);
}
//! Settings: Music Volume
else if (ret == ++Idx)
{
Settings.volume += 10;
if (Settings.volume > 100) Settings.volume = 0;
bgMusic->SetVolume(Settings.volume);
}
//! Settings: SFX Volume
else if (ret == ++Idx)
{
Settings.sfxvolume += 10;
if (Settings.sfxvolume > 100) Settings.sfxvolume = 0;
btnSoundOver->SetVolume(Settings.sfxvolume);
btnSoundClick->SetVolume(Settings.sfxvolume);
btnSoundClick2->SetVolume(Settings.sfxvolume);
}
//! Settings: Game Sound Mode
else if (ret == ++Idx)
{
if (++Settings.gamesound > 2) Settings.gamesound = 0;
}
//! Settings: Game Sound Volume
else if (ret == ++Idx)
{
Settings.gamesoundvolume += 10;
if (Settings.gamesoundvolume > 100) Settings.gamesoundvolume = 0;
}
//! Settings: Music Loop Mode
else if (ret == ++Idx)
{
if (++Settings.musicloopmode > 3) Settings.musicloopmode = 0;
bgMusic->SetLoop(Settings.musicloopmode);
}
//! Settings: Reset BG Music
else if (ret == ++Idx)
{
int result = WindowPrompt(tr( "Reset to default BGM?" ), 0, tr( "Yes" ), tr( "No" ));
if (result)
{
bgMusic->LoadStandard();
bgMusic->Play();
}
}
SetOptionValues();
return MENU_NONE;
}

View File

@ -0,0 +1,42 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef SOUNDSETTINGS_MENU_HPP_
#define SOUNDSETTINGS_MENU_HPP_
#include "SettingsMenu.hpp"
class SoundSettingsMenu : public SettingsMenu
{
public:
SoundSettingsMenu();
virtual int GetType() { return CSoundSettingsMenu; };
protected:
void SetOptionValues();
int GetMenuInternal();
OptionList GuiOptions;
};
#endif

View File

@ -0,0 +1,175 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include "UninstallSM.hpp"
#include "FileOperations/fileops.h"
#include "settings/CSettings.h"
#include "settings/CGameSettings.h"
#include "settings/CGameStatistics.h"
#include "settings/GameTitles.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
#include "usbloader/wbfs.h"
extern int mountMethod;
UninstallSM::UninstallSM(struct discHdr * header)
: SettingsMenu(tr("Uninstall Menu"), &GuiOptions, MENU_NONE)
{
DiscHeader = header;
int Idx = 0;
Options->SetName(Idx++, "%s", tr( "Uninstall Game" ));
Options->SetName(Idx++, "%s", tr( "Reset Playcounter" ));
Options->SetName(Idx++, "%s", tr( "Delete Cover Artwork" ));
Options->SetName(Idx++, "%s", tr( "Delete Disc Artwork" ));
Options->SetName(Idx++, "%s", tr( "Delete Cheat TXT" ));
Options->SetName(Idx++, "%s", tr( "Delete Cheat GCT" ));
SetOptionValues();
}
void UninstallSM::SetOptionValues()
{
int Idx = 0;
//! Settings: Uninstall Game
Options->SetValue(Idx++, " ");
//! Settings: Reset Playcounter
Options->SetValue(Idx++, " ");
//! Settings: Delete Cover Artwork
Options->SetValue(Idx++, " ");
//! Settings: Delete Disc Artwork
Options->SetValue(Idx++, " ");
//! Settings: Delete Cheat TXT
Options->SetValue(Idx++, " ");
//! Settings: Delete Cheat GCT
Options->SetValue(Idx++, " ");
}
int UninstallSM::GetMenuInternal()
{
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: Uninstall Game
if (ret == ++Idx)
{
int choice = WindowPrompt(tr( "Do you really want to delete:" ), GameTitles.GetTitle(DiscHeader), tr( "Yes" ), tr( "Cancel" ));
if (choice == 1)
{
GameSettings.Remove(DiscHeader->id);
GameSettings.Save();
GameStatistics.Remove(DiscHeader->id);
GameStatistics.Save();
int ret = 0;
if(!mountMethod)
ret = WBFS_RemoveGame(DiscHeader->id);
if (ret < 0)
WindowPrompt(tr( "Can't delete:" ), GameTitles.GetTitle(DiscHeader), tr( "OK" ));
else
WindowPrompt(tr( "Successfully deleted:" ), GameTitles.GetTitle(DiscHeader), tr( "OK" ));
return MENU_DISCLIST;
}
}
//! Settings: Reset Playcounter
else if (ret == ++Idx)
{
int result = WindowPrompt(tr( "Are you sure?" ), 0, tr( "Yes" ), tr( "Cancel" ));
if (result == 1)
{
GameStatistics.SetPlayCount(DiscHeader->id, 0);
GameStatistics.Save();
}
}
//! Settings: Delete Cover Artwork
else if (ret == ++Idx)
{
char GameID[7];
snprintf(GameID, sizeof(GameID), "%s", (char *) DiscHeader->id);
char filepath[200];
snprintf(filepath, sizeof(filepath), "%s%s.png", Settings.covers_path, GameID);
int choice = WindowPrompt(tr( "Delete" ), filepath, tr( "Yes" ), tr( "No" ));
if (choice == 1)
if (CheckFile(filepath)) remove(filepath);
}
//! Settings: Delete Disc Artwork
else if (ret == ++Idx)
{
char GameID[7];
snprintf(GameID, sizeof(GameID), "%s", (char *) DiscHeader->id);
char filepath[200];
snprintf(filepath, sizeof(filepath), "%s%s.png", Settings.disc_path, GameID);
int choice = WindowPrompt(tr( "Delete" ), filepath, tr( "Yes" ), tr( "No" ));
if (choice == 1)
if (CheckFile(filepath)) remove(filepath);
}
//! Settings: Delete Cheat TXT
else if (ret == ++Idx)
{
char GameID[7];
snprintf(GameID, sizeof(GameID), "%s", (char *) DiscHeader->id);
char filepath[200];
snprintf(filepath, sizeof(filepath), "%s%s.txt", Settings.TxtCheatcodespath, GameID);
int choice = WindowPrompt(tr( "Delete" ), filepath, tr( "Yes" ), tr( "No" ));
if (choice == 1)
if (CheckFile(filepath)) remove(filepath);
}
//! Settings: Delete Cheat GCT
else if (ret == ++Idx)
{
char GameID[7];
snprintf(GameID, sizeof(GameID), "%s", (char *) DiscHeader->id);
char filepath[200];
snprintf(filepath, sizeof(filepath), "%s%s.gct", Settings.Cheatcodespath, GameID);
int choice = WindowPrompt(tr( "Delete" ), filepath, tr( "Yes" ), tr( "No" ));
if (choice == 1)
if (CheckFile(filepath)) remove(filepath);
}
SetOptionValues();
return MENU_NONE;
}

View File

@ -0,0 +1,44 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef UNINSTALL_MENU_HPP_
#define UNINSTALL_MENU_HPP_
#include "SettingsMenu.hpp"
class UninstallSM : public SettingsMenu
{
public:
UninstallSM(struct discHdr * header);
virtual int GetType() { return CUninstallSM; };
protected:
void SetOptionValues();
int GetMenuInternal();
struct discHdr * DiscHeader;
OptionList GuiOptions;
};
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More