mirror of
https://github.com/wiiu-env/libgui.git
synced 2024-11-13 03:45:07 +01:00
Force braces
This commit is contained in:
parent
2b42bbd60f
commit
482bf28a3a
@ -103,8 +103,9 @@ public:
|
||||
virtual float getDepth() {
|
||||
float zParent = 0.0f;
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
zParent = parentElement->getDepth();
|
||||
}
|
||||
|
||||
return zParent + zoffset;
|
||||
}
|
||||
@ -112,8 +113,9 @@ public:
|
||||
virtual float getCenterX(void) {
|
||||
float pCenterX = 0.0f;
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
pCenterX = parentElement->getCenterX();
|
||||
}
|
||||
|
||||
pCenterX += xoffset + xoffsetDyn;
|
||||
|
||||
@ -144,8 +146,9 @@ public:
|
||||
virtual float getCenterY(void) {
|
||||
float pCenterY = 0.0f;
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
pCenterY = parentElement->getCenterY();
|
||||
}
|
||||
|
||||
pCenterY += yoffset + yoffsetDyn;
|
||||
|
||||
@ -267,8 +270,9 @@ public:
|
||||
if (c >= 0 && c < 5) {
|
||||
state[c] |= s;
|
||||
} else {
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
state[i] |= s;
|
||||
}
|
||||
}
|
||||
stateChan = c;
|
||||
stateChanged(this, s, c);
|
||||
@ -278,8 +282,9 @@ public:
|
||||
if (c >= 0 && c < 5) {
|
||||
state[c] &= ~s;
|
||||
} else {
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
state[i] &= ~s;
|
||||
}
|
||||
}
|
||||
stateChan = c;
|
||||
stateChanged(this, s, c);
|
||||
@ -289,9 +294,11 @@ public:
|
||||
if (c >= 0 && c < 5) {
|
||||
return (state[c] & s) != 0;
|
||||
} else {
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
if ((state[i] & s) != 0)
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
if ((state[i] & s) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -311,8 +318,9 @@ public:
|
||||
|
||||
//!Resets the element's state to STATE_DEFAULT
|
||||
virtual void resetState() {
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
state[i] = STATE_DEFAULT;
|
||||
}
|
||||
stateChan = -1;
|
||||
}
|
||||
|
||||
@ -328,13 +336,15 @@ public:
|
||||
virtual float getAlpha() {
|
||||
float a;
|
||||
|
||||
if (alphaDyn >= 0)
|
||||
if (alphaDyn >= 0) {
|
||||
a = alphaDyn;
|
||||
else
|
||||
} else {
|
||||
a = alpha;
|
||||
}
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
a = (a * parentElement->getAlpha());
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
@ -370,8 +380,9 @@ public:
|
||||
virtual float getScale() {
|
||||
float s = 0.5f * (scaleX + scaleY) * scaleDyn;
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
s *= parentElement->getScale();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -381,8 +392,9 @@ public:
|
||||
virtual float getScaleX() {
|
||||
float s = scaleX * scaleDyn;
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
s *= parentElement->getScaleX();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -392,8 +404,9 @@ public:
|
||||
virtual float getScaleY() {
|
||||
float s = scaleY * scaleDyn;
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
s *= parentElement->getScaleY();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -403,8 +416,9 @@ public:
|
||||
virtual float getScaleZ() {
|
||||
float s = scaleZ;
|
||||
|
||||
if (parentElement)
|
||||
if (parentElement) {
|
||||
s *= parentElement->getScaleZ();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -507,7 +521,7 @@ public:
|
||||
//!Angle of the object
|
||||
virtual float getAngle() const {
|
||||
float r_angle = angle;
|
||||
if (parentElement) r_angle += parentElement->getAngle();
|
||||
if (parentElement) { r_angle += parentElement->getAngle(); }
|
||||
return r_angle;
|
||||
}
|
||||
|
||||
|
@ -51,15 +51,15 @@ public:
|
||||
//!Gets the image width
|
||||
//!\return image width
|
||||
int32_t getWidth() const {
|
||||
if (texture) return texture->surface.width;
|
||||
else return 0;
|
||||
if (texture) { return texture->surface.width; }
|
||||
else { return 0; }
|
||||
};
|
||||
|
||||
//!Gets the image height
|
||||
//!\return image height
|
||||
int32_t getHeight() const {
|
||||
if (texture) return texture->surface.height;
|
||||
else return 0;
|
||||
if (texture) { return texture->surface.height; }
|
||||
else { return 0; }
|
||||
};
|
||||
|
||||
//! release memory of the image data
|
||||
|
@ -35,44 +35,57 @@ public:
|
||||
uint32_t remapWiiMoteButtons(uint32_t buttons) {
|
||||
uint32_t conv_buttons = 0;
|
||||
|
||||
if (buttons & WPAD_BUTTON_LEFT)
|
||||
if (buttons & WPAD_BUTTON_LEFT) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_LEFT;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_RIGHT)
|
||||
if (buttons & WPAD_BUTTON_RIGHT) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_RIGHT;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_DOWN)
|
||||
if (buttons & WPAD_BUTTON_DOWN) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_DOWN;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_UP)
|
||||
if (buttons & WPAD_BUTTON_UP) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_UP;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_PLUS)
|
||||
if (buttons & WPAD_BUTTON_PLUS) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_PLUS;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_2)
|
||||
if (buttons & WPAD_BUTTON_2) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_2;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_1)
|
||||
if (buttons & WPAD_BUTTON_1) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_1;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_B)
|
||||
if (buttons & WPAD_BUTTON_B) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_B;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_A)
|
||||
if (buttons & WPAD_BUTTON_A) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_A;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_MINUS)
|
||||
if (buttons & WPAD_BUTTON_MINUS) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_MINUS;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_Z)
|
||||
if (buttons & WPAD_BUTTON_Z) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_Z;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_C)
|
||||
if (buttons & WPAD_BUTTON_C) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_C;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_BUTTON_HOME)
|
||||
if (buttons & WPAD_BUTTON_HOME) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_HOME;
|
||||
}
|
||||
|
||||
return conv_buttons;
|
||||
}
|
||||
@ -80,50 +93,65 @@ public:
|
||||
uint32_t remapClassicButtons(uint32_t buttons) {
|
||||
uint32_t conv_buttons = 0;
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_LEFT)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_LEFT) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_LEFT;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_RIGHT)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_RIGHT) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_RIGHT;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_DOWN)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_DOWN) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_DOWN;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_UP)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_UP) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_UP;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_PLUS)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_PLUS) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_PLUS;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_X)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_X) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_X;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_Y)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_Y) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_Y;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_B)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_B) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_B;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_A)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_A) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_A;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_MINUS)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_MINUS) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_MINUS;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_HOME)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_HOME) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_HOME;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_ZR)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_ZR) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_ZR;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_ZL)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_ZL) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_ZL;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_R)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_R) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_R;
|
||||
}
|
||||
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_L)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_L) {
|
||||
conv_buttons |= GuiTrigger::BUTTON_L;
|
||||
}
|
||||
|
||||
return conv_buttons;
|
||||
}
|
||||
@ -149,8 +177,9 @@ public:
|
||||
WPADExtensionType controller_type;
|
||||
|
||||
//! check if the controller is connected
|
||||
if (WPADProbe(getChanByInt(chanIdx - 1), &controller_type) != 0)
|
||||
if (WPADProbe(getChanByInt(chanIdx - 1), &controller_type) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KPADRead(getChanByInt(chanIdx - 1), &kpadData, 1);
|
||||
|
||||
@ -170,10 +199,11 @@ public:
|
||||
data.x = (width >> 1) * kpadData.pos.x;
|
||||
data.y = (height >> 1) * (-kpadData.pos.y);
|
||||
|
||||
if (kpadData.angle.y > 0.0f)
|
||||
if (kpadData.angle.y > 0.0f) {
|
||||
data.pointerAngle = (-kpadData.angle.x + 1.0f) * 0.5f * 180.0f;
|
||||
else
|
||||
} else {
|
||||
data.pointerAngle = (kpadData.angle.x + 1.0f) * 0.5f * 180.0f - 180.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -96,15 +96,17 @@ static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, GX2SurfaceDim
|
||||
colorBuffer->surface.alignment = 0;
|
||||
colorBuffer->surface.pitch = 0;
|
||||
uint32_t i;
|
||||
for (i = 0; i < 13; i++)
|
||||
for (i = 0; i < 13; i++) {
|
||||
colorBuffer->surface.mipLevelOffset[i] = 0;
|
||||
}
|
||||
colorBuffer->viewMip = 0;
|
||||
colorBuffer->viewFirstSlice = 0;
|
||||
colorBuffer->viewNumSlices = depth;
|
||||
colorBuffer->aaBuffer = NULL;
|
||||
colorBuffer->aaSize = 0;
|
||||
for (i = 0; i < 5; i++)
|
||||
for (i = 0; i < 5; i++) {
|
||||
colorBuffer->regs[i] = 0;
|
||||
}
|
||||
|
||||
GX2CalcSurfaceSizeAndAlignment(&colorBuffer->surface);
|
||||
GX2InitColorBufferRegs(colorBuffer);
|
||||
@ -139,15 +141,17 @@ static inline void GX2InitTexture(GX2Texture *tex, uint32_t width, uint32_t heig
|
||||
tex->surface.alignment = 0;
|
||||
tex->surface.pitch = 0;
|
||||
uint32_t i;
|
||||
for (i = 0; i < 13; i++)
|
||||
for (i = 0; i < 13; i++) {
|
||||
tex->surface.mipLevelOffset[i] = 0;
|
||||
}
|
||||
tex->viewFirstMip = 0;
|
||||
tex->viewNumMips = mipLevels;
|
||||
tex->viewFirstSlice = 0;
|
||||
tex->viewNumSlices = depth;
|
||||
tex->compMap = texture_comp_selector[format & 0x3f];
|
||||
for (i = 0; i < 5; i++)
|
||||
for (i = 0; i < 5; i++) {
|
||||
tex->regs[i] = 0;
|
||||
}
|
||||
|
||||
GX2CalcSurfaceSizeAndAlignment(&tex->surface);
|
||||
GX2InitTextureRegs(tex);
|
||||
|
@ -67,8 +67,8 @@ public:
|
||||
|
||||
//!> Get a buffer at a position
|
||||
uint8_t *GetBuffer(int32_t pos) {
|
||||
if (!Valid(pos)) return NULL;
|
||||
else return SoundBuffer[pos];
|
||||
if (!Valid(pos)) { return NULL; }
|
||||
else { return SoundBuffer[pos]; }
|
||||
};
|
||||
|
||||
//!> Get current buffer size
|
||||
@ -78,8 +78,8 @@ public:
|
||||
|
||||
//!> Get buffer size at position
|
||||
uint32_t GetBufferSize(int32_t pos) {
|
||||
if (!Valid(pos)) return 0;
|
||||
else return BufferSize[pos];
|
||||
if (!Valid(pos)) { return 0; }
|
||||
else { return BufferSize[pos]; }
|
||||
};
|
||||
|
||||
//!> Is current buffer ready
|
||||
@ -89,8 +89,8 @@ public:
|
||||
|
||||
//!> Is a buffer at a position ready
|
||||
bool IsBufferReady(int32_t pos) {
|
||||
if (!Valid(pos)) return false;
|
||||
else return BufferReady[pos];
|
||||
if (!Valid(pos)) { return false; }
|
||||
else { return BufferReady[pos]; }
|
||||
};
|
||||
|
||||
//!> Set a buffer at a position to a ready state
|
||||
@ -110,8 +110,8 @@ public:
|
||||
}
|
||||
|
||||
inline uint16_t Prev() {
|
||||
if (Size() == 0) return 0;
|
||||
else return ((int32_t) which - 1 < 0) ? Size() - 1 : which - 1;
|
||||
if (Size() == 0) { return 0; }
|
||||
else { return ((int32_t) which - 1 < 0) ? Size() - 1 : which - 1; }
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -38,8 +38,9 @@
|
||||
class SoundHandler : public CThread {
|
||||
public:
|
||||
static SoundHandler *instance() {
|
||||
if (!handlerInstance)
|
||||
if (!handlerInstance) {
|
||||
handlerInstance = new SoundHandler();
|
||||
}
|
||||
return handlerInstance;
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,9 @@ public:
|
||||
}
|
||||
|
||||
void play(const uint8_t *buffer, uint32_t bufferSize, const uint8_t *nextBuffer, uint32_t nextBufSize, uint16_t format, uint32_t sampleRate) {
|
||||
if (!voice)
|
||||
if (!voice) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&voiceBuffer, 0, sizeof(voiceBuffer));
|
||||
|
||||
@ -95,8 +96,9 @@ public:
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if (voice)
|
||||
if (voice) {
|
||||
AXSetVoiceState(voice, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void setVolume(uint32_t vol) {
|
||||
@ -127,8 +129,9 @@ public:
|
||||
}
|
||||
|
||||
uint32_t getInternState() const {
|
||||
if (voice)
|
||||
if (voice) {
|
||||
return ((uint32_t *) voice)[1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,9 @@ public:
|
||||
//! allocate the stack
|
||||
pThreadStack = (uint8_t *) memalign(0x20, iStackSize);
|
||||
//! create the thread
|
||||
if (pThread && pThreadStack)
|
||||
if (pThread && pThreadStack) {
|
||||
OSCreateThread(pThread, &CThread::threadCallback, 1, (char *) this, pThreadStack + iStackSize, iStackSize, iPriority, iAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
//! destructor
|
||||
@ -55,43 +56,51 @@ public:
|
||||
|
||||
//! Thread entry function
|
||||
virtual void executeThread(void) {
|
||||
if (pCallback)
|
||||
if (pCallback) {
|
||||
pCallback(this, pCallbackArg);
|
||||
}
|
||||
}
|
||||
|
||||
//! Suspend thread
|
||||
virtual void suspendThread(void) {
|
||||
if (isThreadSuspended())
|
||||
if (isThreadSuspended()) {
|
||||
return;
|
||||
if (pThread)
|
||||
}
|
||||
if (pThread) {
|
||||
OSSuspendThread(pThread);
|
||||
}
|
||||
}
|
||||
|
||||
//! Resume thread
|
||||
virtual void resumeThread(void) {
|
||||
if (!isThreadSuspended())
|
||||
if (!isThreadSuspended()) {
|
||||
return;
|
||||
if (pThread)
|
||||
}
|
||||
if (pThread) {
|
||||
OSResumeThread(pThread);
|
||||
}
|
||||
}
|
||||
|
||||
//! Set thread priority
|
||||
virtual void setThreadPriority(int32_t prio) {
|
||||
if (pThread)
|
||||
if (pThread) {
|
||||
OSSetThreadPriority(pThread, prio);
|
||||
}
|
||||
}
|
||||
|
||||
//! Check if thread is suspended
|
||||
virtual bool isThreadSuspended(void) const {
|
||||
if (pThread)
|
||||
if (pThread) {
|
||||
return OSIsThreadSuspended(pThread);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Check if thread is terminated
|
||||
virtual bool isThreadTerminated(void) const {
|
||||
if (pThread)
|
||||
if (pThread) {
|
||||
return OSIsThreadTerminated(pThread);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -104,16 +113,19 @@ public:
|
||||
virtual void shutdownThread(void) {
|
||||
//! wait for thread to finish
|
||||
if (pThread && !(iAttributes & eAttributeDetach)) {
|
||||
if (isThreadSuspended())
|
||||
if (isThreadSuspended()) {
|
||||
resumeThread();
|
||||
}
|
||||
|
||||
OSJoinThread(pThread, NULL);
|
||||
}
|
||||
//! free the thread stack buffer
|
||||
if (pThreadStack)
|
||||
if (pThreadStack) {
|
||||
free(pThreadStack);
|
||||
if (pThread)
|
||||
}
|
||||
if (pThread) {
|
||||
free(pThread);
|
||||
}
|
||||
|
||||
pThread = NULL;
|
||||
pThreadStack = NULL;
|
||||
|
@ -26,8 +26,9 @@ class CursorDrawer {
|
||||
|
||||
public:
|
||||
static CursorDrawer *getInstance() {
|
||||
if (!instance)
|
||||
if (!instance) {
|
||||
instance = new CursorDrawer();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -40,7 +41,7 @@ public:
|
||||
|
||||
static void draw(float x, float y) {
|
||||
CursorDrawer *cur_instance = getInstance();
|
||||
if (cur_instance == NULL) return;
|
||||
if (cur_instance == NULL) { return; }
|
||||
cur_instance->draw_Cursor(x, y);
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,12 @@ public:
|
||||
}
|
||||
|
||||
virtual ~FetchShader() {
|
||||
if (fetchShaderProgramm)
|
||||
if (fetchShaderProgramm) {
|
||||
free(fetchShaderProgramm);
|
||||
if (fetchShader)
|
||||
}
|
||||
if (fetchShader) {
|
||||
delete fetchShader;
|
||||
}
|
||||
}
|
||||
|
||||
GX2FetchShader *getFetchShader() const {
|
||||
|
@ -31,40 +31,50 @@ public:
|
||||
|
||||
virtual ~PixelShader() {
|
||||
if (pixelShader) {
|
||||
if (pixelShader->program)
|
||||
if (pixelShader->program) {
|
||||
free(pixelShader->program);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < pixelShader->uniformBlockCount; i++)
|
||||
for (uint32_t i = 0; i < pixelShader->uniformBlockCount; i++) {
|
||||
free((void *) pixelShader->uniformBlocks[i].name);
|
||||
}
|
||||
|
||||
if (pixelShader->uniformBlocks)
|
||||
if (pixelShader->uniformBlocks) {
|
||||
free((void *) pixelShader->uniformBlocks);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < pixelShader->uniformVarCount; i++)
|
||||
for (uint32_t i = 0; i < pixelShader->uniformVarCount; i++) {
|
||||
free((void *) pixelShader->uniformVars[i].name);
|
||||
}
|
||||
|
||||
if (pixelShader->uniformVars)
|
||||
if (pixelShader->uniformVars) {
|
||||
free((void *) pixelShader->uniformVars);
|
||||
}
|
||||
|
||||
if (pixelShader->initialValues)
|
||||
if (pixelShader->initialValues) {
|
||||
free((void *) pixelShader->initialValues);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < pixelShader->samplerVarCount; i++)
|
||||
for (uint32_t i = 0; i < pixelShader->samplerVarCount; i++) {
|
||||
free((void *) pixelShader->samplerVars[i].name);
|
||||
}
|
||||
|
||||
if (pixelShader->samplerVars)
|
||||
if (pixelShader->samplerVars) {
|
||||
free((void *) pixelShader->samplerVars);
|
||||
}
|
||||
|
||||
if (pixelShader->loopVars)
|
||||
if (pixelShader->loopVars) {
|
||||
free((void *) pixelShader->loopVars);
|
||||
}
|
||||
|
||||
free(pixelShader);
|
||||
}
|
||||
}
|
||||
|
||||
void setProgram(const uint32_t *program, const uint32_t &programSize, const uint32_t *regs, const uint32_t ®sSize) {
|
||||
if (!pixelShader)
|
||||
if (!pixelShader) {
|
||||
return;
|
||||
}
|
||||
|
||||
//! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100
|
||||
pixelShader->size = programSize;
|
||||
@ -78,8 +88,9 @@ public:
|
||||
}
|
||||
|
||||
void addUniformVar(const GX2UniformVar &var) {
|
||||
if (!pixelShader)
|
||||
if (!pixelShader) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t idx = pixelShader->uniformVarCount;
|
||||
|
||||
@ -100,8 +111,9 @@ public:
|
||||
}
|
||||
|
||||
void addSamplerVar(const GX2SamplerVar &var) {
|
||||
if (!pixelShader)
|
||||
if (!pixelShader) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t idx = pixelShader->samplerVarCount;
|
||||
|
||||
|
@ -35,46 +35,58 @@ public:
|
||||
delete[] attributes;
|
||||
|
||||
if (vertexShader) {
|
||||
if (vertexShader->program)
|
||||
if (vertexShader->program) {
|
||||
free(vertexShader->program);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < vertexShader->uniformBlockCount; i++)
|
||||
for (uint32_t i = 0; i < vertexShader->uniformBlockCount; i++) {
|
||||
free((void *) vertexShader->uniformBlocks[i].name);
|
||||
}
|
||||
|
||||
if (vertexShader->uniformBlocks)
|
||||
if (vertexShader->uniformBlocks) {
|
||||
free((void *) vertexShader->uniformBlocks);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < vertexShader->uniformVarCount; i++)
|
||||
for (uint32_t i = 0; i < vertexShader->uniformVarCount; i++) {
|
||||
free((void *) vertexShader->uniformVars[i].name);
|
||||
}
|
||||
|
||||
if (vertexShader->uniformVars)
|
||||
if (vertexShader->uniformVars) {
|
||||
free((void *) vertexShader->uniformVars);
|
||||
}
|
||||
|
||||
if (vertexShader->initialValues)
|
||||
if (vertexShader->initialValues) {
|
||||
free((void *) vertexShader->initialValues);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < vertexShader->samplerVarCount; i++)
|
||||
for (uint32_t i = 0; i < vertexShader->samplerVarCount; i++) {
|
||||
free((void *) vertexShader->samplerVars[i].name);
|
||||
}
|
||||
|
||||
if (vertexShader->samplerVars)
|
||||
if (vertexShader->samplerVars) {
|
||||
free((void *) vertexShader->samplerVars);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < vertexShader->attribVarCount; i++)
|
||||
for (uint32_t i = 0; i < vertexShader->attribVarCount; i++) {
|
||||
free((void *) vertexShader->attribVars[i].name);
|
||||
}
|
||||
|
||||
if (vertexShader->attribVars)
|
||||
if (vertexShader->attribVars) {
|
||||
free((void *) vertexShader->attribVars);
|
||||
}
|
||||
|
||||
if (vertexShader->loopVars)
|
||||
if (vertexShader->loopVars) {
|
||||
free((void *) vertexShader->loopVars);
|
||||
}
|
||||
|
||||
free(vertexShader);
|
||||
}
|
||||
}
|
||||
|
||||
void setProgram(const uint32_t *program, const uint32_t &programSize, const uint32_t *regs, const uint32_t ®sSize) {
|
||||
if (!vertexShader)
|
||||
if (!vertexShader) {
|
||||
return;
|
||||
}
|
||||
|
||||
//! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100
|
||||
vertexShader->size = programSize;
|
||||
@ -88,8 +100,9 @@ public:
|
||||
}
|
||||
|
||||
void addUniformVar(const GX2UniformVar &var) {
|
||||
if (!vertexShader)
|
||||
if (!vertexShader) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t idx = vertexShader->uniformVarCount;
|
||||
|
||||
@ -110,8 +123,9 @@ public:
|
||||
}
|
||||
|
||||
void addAttribVar(const GX2AttribVar &var) {
|
||||
if (!vertexShader)
|
||||
if (!vertexShader) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t idx = vertexShader->attribVarCount;
|
||||
|
||||
|
@ -54,8 +54,9 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) {
|
||||
//! the .data sections which is needed for a normal application to re-init
|
||||
//! this will be added with launching as RPX
|
||||
iFd = ::open(filepath.c_str(), openMode);
|
||||
if (iFd < 0)
|
||||
if (iFd < 0) {
|
||||
return iFd;
|
||||
}
|
||||
|
||||
|
||||
filesize = ::lseek(iFd, 0, SEEK_END);
|
||||
@ -74,8 +75,9 @@ int32_t CFile::open(const uint8_t *mem, int32_t size) {
|
||||
}
|
||||
|
||||
void CFile::close() {
|
||||
if (iFd >= 0)
|
||||
if (iFd >= 0) {
|
||||
::close(iFd);
|
||||
}
|
||||
|
||||
iFd = -1;
|
||||
mem_file = NULL;
|
||||
@ -86,18 +88,21 @@ void CFile::close() {
|
||||
int32_t CFile::read(uint8_t *ptr, size_t size) {
|
||||
if (iFd >= 0) {
|
||||
int32_t ret = ::read(iFd, ptr, size);
|
||||
if (ret > 0)
|
||||
if (ret > 0) {
|
||||
pos += ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t readsize = size;
|
||||
|
||||
if (readsize > (int64_t) (filesize - pos))
|
||||
if (readsize > (int64_t) (filesize - pos)) {
|
||||
readsize = filesize - pos;
|
||||
}
|
||||
|
||||
if (readsize <= 0)
|
||||
if (readsize <= 0) {
|
||||
return readsize;
|
||||
}
|
||||
|
||||
if (mem_file != NULL) {
|
||||
memcpy(ptr, mem_file + pos, readsize);
|
||||
@ -113,8 +118,9 @@ int32_t CFile::write(const uint8_t *ptr, size_t size) {
|
||||
size_t done = 0;
|
||||
while (done < size) {
|
||||
int32_t ret = ::write(iFd, ptr, size - done);
|
||||
if (ret <= 0)
|
||||
if (ret <= 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ptr += ret;
|
||||
done += ret;
|
||||
@ -144,8 +150,9 @@ int32_t CFile::seek(long int offset, int32_t origin) {
|
||||
pos = newPos;
|
||||
}
|
||||
|
||||
if (iFd >= 0)
|
||||
if (iFd >= 0) {
|
||||
ret = ::lseek(iFd, pos, SEEK_SET);
|
||||
}
|
||||
|
||||
if (mem_file != NULL) {
|
||||
if (pos > filesize) {
|
||||
|
@ -30,11 +30,13 @@ public:
|
||||
int32_t open(const uint8_t *memory, int32_t memsize);
|
||||
|
||||
BOOL isOpen() const {
|
||||
if (iFd >= 0)
|
||||
if (iFd >= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mem_file)
|
||||
if (mem_file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -68,10 +68,10 @@ FreeTypeGX::~FreeTypeGX() {
|
||||
*/
|
||||
|
||||
wchar_t *FreeTypeGX::charToWideChar(const char *strChar) {
|
||||
if (!strChar) return NULL;
|
||||
if (!strChar) { return NULL; }
|
||||
|
||||
wchar_t *strWChar = new(std::nothrow) wchar_t[strlen(strChar) + 1];
|
||||
if (!strWChar) return NULL;
|
||||
if (!strWChar) { return NULL; }
|
||||
|
||||
int32_t bt = mbstowcs(strWChar, strChar, strlen(strChar));
|
||||
if (bt > 0) {
|
||||
@ -95,27 +95,29 @@ char *FreeTypeGX::wideCharToUTF8(const wchar_t *strChar) {
|
||||
|
||||
for (size_t i = 0; strChar[i]; ++i) {
|
||||
wc = strChar[i];
|
||||
if (wc < 0x80)
|
||||
if (wc < 0x80) {
|
||||
++len;
|
||||
else if (wc < 0x800)
|
||||
} else if (wc < 0x800) {
|
||||
len += 2;
|
||||
else if (wc < 0x10000)
|
||||
} else if (wc < 0x10000) {
|
||||
len += 3;
|
||||
else
|
||||
} else {
|
||||
len += 4;
|
||||
}
|
||||
}
|
||||
|
||||
char *pOut = new(std::nothrow) char[len];
|
||||
if (!pOut)
|
||||
if (!pOut) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t n = 0;
|
||||
|
||||
for (size_t i = 0; strChar[i]; ++i) {
|
||||
wc = strChar[i];
|
||||
if (wc < 0x80)
|
||||
if (wc < 0x80) {
|
||||
pOut[n++] = (char) wc;
|
||||
else if (wc < 0x800) {
|
||||
} else if (wc < 0x800) {
|
||||
pOut[n++] = (char) ((wc >> 6) | 0xC0);
|
||||
pOut[n++] = (char) ((wc & 0x3F) | 0x80);
|
||||
} else if (wc < 0x10000) {
|
||||
@ -144,8 +146,9 @@ void FreeTypeGX::unloadFont() {
|
||||
for (itr = fontData.begin(); itr != fontData.end(); itr++) {
|
||||
for (itr2 = itr->second.ftgxCharMap.begin(); itr2 != itr->second.ftgxCharMap.end(); itr2++) {
|
||||
if (itr2->second.texture) {
|
||||
if (itr2->second.texture->surface.image)
|
||||
if (itr2->second.texture->surface.image) {
|
||||
free(itr2->second.texture->surface.image);
|
||||
}
|
||||
|
||||
delete itr2->second.texture;
|
||||
itr2->second.texture = NULL;
|
||||
@ -194,10 +197,12 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
|
||||
|
||||
textureWidth = ALIGN4(glyphBitmap->width);
|
||||
textureHeight = ALIGN4(glyphBitmap->rows);
|
||||
if (textureWidth == 0)
|
||||
if (textureWidth == 0) {
|
||||
textureWidth = 4;
|
||||
if (textureHeight == 0)
|
||||
}
|
||||
if (textureHeight == 0) {
|
||||
textureHeight = 4;
|
||||
}
|
||||
|
||||
ftgxCharData *charData = &ftData->ftgxCharMap[charCode];
|
||||
charData->renderOffsetX = (int16_t) ftFace->glyph->bitmap_left;
|
||||
@ -232,7 +237,7 @@ uint16_t FreeTypeGX::cacheGlyphDataComplete(int16_t pixelSize) {
|
||||
|
||||
FT_ULong charCode = FT_Get_First_Char(ftFace, &gIndex);
|
||||
while (gIndex != 0) {
|
||||
if (cacheGlyphData(charCode, pixelSize) != NULL) ++i;
|
||||
if (cacheGlyphData(charCode, pixelSize) != NULL) { ++i; }
|
||||
charCode = FT_Get_Next_Char(ftFace, charCode, &gIndex);
|
||||
}
|
||||
return (uint16_t) (i);
|
||||
@ -250,8 +255,9 @@ uint16_t FreeTypeGX::cacheGlyphDataComplete(int16_t pixelSize) {
|
||||
|
||||
void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
|
||||
charData->texture->surface.image = (uint8_t *) memalign(charData->texture->surface.alignment, charData->texture->surface.imageSize);
|
||||
if (!charData->texture->surface.image)
|
||||
if (!charData->texture->surface.image) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(charData->texture->surface.image, 0x00, charData->texture->surface.imageSize);
|
||||
|
||||
@ -277,11 +283,11 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
|
||||
* @param format Positional format of the string.
|
||||
*/
|
||||
int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
|
||||
if (format & FTGX_JUSTIFY_LEFT)
|
||||
if (format & FTGX_JUSTIFY_LEFT) {
|
||||
return 0;
|
||||
else if (format & FTGX_JUSTIFY_CENTER)
|
||||
} else if (format & FTGX_JUSTIFY_CENTER) {
|
||||
return -(width >> 1);
|
||||
else if (format & FTGX_JUSTIFY_RIGHT) return -width;
|
||||
} else if (format & FTGX_JUSTIFY_RIGHT) { return -width; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -295,7 +301,7 @@ int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
|
||||
*/
|
||||
int16_t FreeTypeGX::getStyleOffsetHeight(int16_t format, uint16_t pixelSize) {
|
||||
std::map<int16_t, ftGX2Data>::iterator itr = fontData.find(pixelSize);
|
||||
if (itr == fontData.end()) return 0;
|
||||
if (itr == fontData.end()) { return 0; }
|
||||
|
||||
switch (format & FTGX_ALIGN_MASK) {
|
||||
case FTGX_ALIGN_TOP:
|
||||
@ -339,8 +345,9 @@ int16_t FreeTypeGX::getStyleOffsetHeight(int16_t format, uint16_t pixelSize) {
|
||||
|
||||
uint16_t FreeTypeGX::drawText(CVideo *video, int16_t x, int16_t y, int16_t z, const wchar_t *text, int16_t pixelSize, const glm::vec4 &color, uint16_t textStyle, uint16_t textWidth, const float &textBlur, const float &colorBlurIntensity,
|
||||
const glm::vec4 &blurColor, const float &internalRenderingScale) {
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t fullTextWidth = (textWidth > 0) ? textWidth : getWidth(text, pixelSize);
|
||||
uint16_t x_pos = x, printed = 0;
|
||||
@ -386,7 +393,7 @@ uint16_t FreeTypeGX::drawText(CVideo *video, int16_t x, int16_t y, int16_t z, co
|
||||
* @return The width of the text string in pixels.
|
||||
*/
|
||||
uint16_t FreeTypeGX::getWidth(const wchar_t *text, int16_t pixelSize) {
|
||||
if (!text) return 0;
|
||||
if (!text) { return 0; }
|
||||
|
||||
uint16_t strWidth = 0;
|
||||
FT_Vector pairDelta;
|
||||
@ -452,8 +459,9 @@ uint16_t FreeTypeGX::getHeight(const wchar_t *text, int16_t pixelSize) {
|
||||
*
|
||||
*/
|
||||
void FreeTypeGX::getOffset(const wchar_t *text, int16_t pixelSize, uint16_t widthLimit) {
|
||||
if (fontData.find(pixelSize) != fontData.end())
|
||||
if (fontData.find(pixelSize) != fontData.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t strMax = 0, strMin = 9999;
|
||||
uint16_t currWidth = 0;
|
||||
@ -461,7 +469,7 @@ void FreeTypeGX::getOffset(const wchar_t *text, int16_t pixelSize, uint16_t widt
|
||||
int32_t i = 0;
|
||||
|
||||
while (text[i]) {
|
||||
if (widthLimit > 0 && currWidth >= widthLimit) break;
|
||||
if (widthLimit > 0 && currWidth >= widthLimit) { break; }
|
||||
|
||||
ftgxCharData *glyphData = cacheGlyphData(text[i], pixelSize);
|
||||
|
||||
|
@ -12,8 +12,9 @@ GameBgImage::~GameBgImage() {
|
||||
}
|
||||
|
||||
void GameBgImage::draw(CVideo *pVideo) {
|
||||
if (!getImageData() || !getImageData()->getTexture())
|
||||
if (!getImageData() || !getImageData()->getTexture()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//! first setup 2D GUI positions
|
||||
float currPosX = getCenterX();
|
||||
|
@ -60,52 +60,52 @@ GuiButton::~GuiButton() {
|
||||
|
||||
void GuiButton::setImage(GuiImage *img) {
|
||||
image = img;
|
||||
if (img) img->setParent(this);
|
||||
if (img) { img->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setImageOver(GuiImage *img) {
|
||||
imageOver = img;
|
||||
if (img) img->setParent(this);
|
||||
if (img) { img->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setImageHold(GuiImage *img) {
|
||||
imageHold = img;
|
||||
if (img) img->setParent(this);
|
||||
if (img) { img->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setImageClick(GuiImage *img) {
|
||||
imageClick = img;
|
||||
if (img) img->setParent(this);
|
||||
if (img) { img->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setIcon(GuiImage *img) {
|
||||
icon = img;
|
||||
if (img) img->setParent(this);
|
||||
if (img) { img->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setIconOver(GuiImage *img) {
|
||||
iconOver = img;
|
||||
if (img) img->setParent(this);
|
||||
if (img) { img->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setLabel(GuiText *txt, int32_t n) {
|
||||
label[n] = txt;
|
||||
if (txt) txt->setParent(this);
|
||||
if (txt) { txt->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setLabelOver(GuiText *txt, int32_t n) {
|
||||
labelOver[n] = txt;
|
||||
if (txt) txt->setParent(this);
|
||||
if (txt) { txt->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setLabelHold(GuiText *txt, int32_t n) {
|
||||
labelHold[n] = txt;
|
||||
if (txt) txt->setParent(this);
|
||||
if (txt) { txt->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setLabelClick(GuiText *txt, int32_t n) {
|
||||
labelClick[n] = txt;
|
||||
if (txt) txt->setParent(this);
|
||||
if (txt) { txt->setParent(this); }
|
||||
}
|
||||
|
||||
void GuiButton::setSoundOver(GuiSound *snd) {
|
||||
@ -143,36 +143,41 @@ void GuiButton::resetState(void) {
|
||||
* Draw the button on screen
|
||||
*/
|
||||
void GuiButton::draw(CVideo *v) {
|
||||
if (!this->isVisible())
|
||||
if (!this->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// draw image
|
||||
if ((isDrawOverOnlyWhenSelected() && (isStateSet(STATE_SELECTED) && imageOver)) ||
|
||||
(!isDrawOverOnlyWhenSelected() && (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && imageOver)))
|
||||
(!isDrawOverOnlyWhenSelected() && (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && imageOver))) {
|
||||
imageOver->draw(v);
|
||||
else if (image)
|
||||
} else if (image) {
|
||||
image->draw(v);
|
||||
}
|
||||
|
||||
if ((isDrawOverOnlyWhenSelected() && (isStateSet(STATE_SELECTED) && iconOver)) ||
|
||||
(!isDrawOverOnlyWhenSelected() && (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && iconOver)))
|
||||
(!isDrawOverOnlyWhenSelected() && (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && iconOver))) {
|
||||
iconOver->draw(v);
|
||||
else if (icon)
|
||||
} else if (icon) {
|
||||
icon->draw(v);
|
||||
}
|
||||
|
||||
// draw text
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
if (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && labelOver[i])
|
||||
if (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && labelOver[i]) {
|
||||
labelOver[i]->draw(v);
|
||||
else if (label[i])
|
||||
} else if (label[i]) {
|
||||
label[i]->draw(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GuiButton::update(GuiController *c) {
|
||||
if (!c || isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx))
|
||||
if (!c || isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx)) {
|
||||
return;
|
||||
else if (parentElement && (parentElement->isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx)))
|
||||
} else if (parentElement && (parentElement->isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectable) {
|
||||
if (c->data.validPointer && this->isInside(c->data.x, c->data.y)) {
|
||||
@ -182,8 +187,9 @@ void GuiButton::update(GuiController *c) {
|
||||
//if(this->isRumbleActive())
|
||||
// this->rumble(t->chan);
|
||||
|
||||
if (soundOver)
|
||||
if (soundOver) {
|
||||
soundOver->Play();
|
||||
}
|
||||
|
||||
if (effectsOver && !effects) {
|
||||
// initiate effects
|
||||
@ -208,8 +214,9 @@ void GuiButton::update(GuiController *c) {
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < iMaxGuiTriggers; i++) {
|
||||
if (!trigger[i])
|
||||
if (!trigger[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// button triggers
|
||||
if (clickable) {
|
||||
@ -218,8 +225,9 @@ void GuiButton::update(GuiController *c) {
|
||||
|
||||
if (!clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE)
|
||||
&& (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
|
||||
if (soundClick)
|
||||
if (soundClick) {
|
||||
soundClick->Play();
|
||||
}
|
||||
|
||||
clickedTrigger = trigger[i];
|
||||
|
||||
@ -249,8 +257,9 @@ void GuiButton::update(GuiController *c) {
|
||||
&& (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
|
||||
heldTrigger = trigger[i];
|
||||
|
||||
if (!isStateSet(STATE_HELD, c->chanIdx))
|
||||
if (!isStateSet(STATE_HELD, c->chanIdx)) {
|
||||
setState(STATE_HELD, c->chanIdx);
|
||||
}
|
||||
|
||||
held(this, c, trigger[i]);
|
||||
} else if (isStateSet(STATE_HELD, c->chanIdx) && (heldTrigger == trigger[i]) && (!isHeld || trigger[i]->released(c))) {
|
||||
|
@ -54,10 +54,11 @@ void GuiDragListener::setTrigger(GuiTrigger *t, int32_t idx) {
|
||||
}
|
||||
|
||||
void GuiDragListener::update(GuiController *c) {
|
||||
if (!c || isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx))
|
||||
if (!c || isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx)) {
|
||||
return;
|
||||
else if (parentElement && (parentElement->isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx)))
|
||||
} else if (parentElement && (parentElement->isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT, c->chanIdx))) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < iMaxGuiTriggers; i++) {
|
||||
if (!trigger[i]) {
|
||||
@ -71,7 +72,7 @@ void GuiDragListener::update(GuiController *c) {
|
||||
int32_t dx = c->data.x - c->lastData.x;
|
||||
int32_t dy = c->data.y - c->lastData.y;
|
||||
|
||||
if (dx == 0 && dy == 0) continue;
|
||||
if (dx == 0 && dy == 0) { continue; }
|
||||
|
||||
dragged(this, c, trigger[i], dx, dy);
|
||||
}
|
||||
|
@ -33,8 +33,9 @@ GuiElement::GuiElement() {
|
||||
scaleX = 1.0f;
|
||||
scaleY = 1.0f;
|
||||
scaleZ = 1.0f;
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
state[i] = STATE_DEFAULT;
|
||||
}
|
||||
stateChan = -1;
|
||||
parentElement = NULL;
|
||||
rumble = true;
|
||||
@ -123,25 +124,29 @@ void GuiElement::setEffect(int32_t eff, int32_t amount, int32_t target) {
|
||||
if (eff & EFFECT_SLIDE_IN) {
|
||||
// these calculations overcompensate a little
|
||||
if (eff & EFFECT_SLIDE_TOP) {
|
||||
if (eff & EFFECT_SLIDE_FROM)
|
||||
if (eff & EFFECT_SLIDE_FROM) {
|
||||
yoffsetDyn = (int32_t) -getHeight() * scaleY;
|
||||
else
|
||||
} else {
|
||||
yoffsetDyn = -screenheight;
|
||||
}
|
||||
} else if (eff & EFFECT_SLIDE_LEFT) {
|
||||
if (eff & EFFECT_SLIDE_FROM)
|
||||
if (eff & EFFECT_SLIDE_FROM) {
|
||||
xoffsetDyn = (int32_t) -getWidth() * scaleX;
|
||||
else
|
||||
} else {
|
||||
xoffsetDyn = -screenwidth;
|
||||
}
|
||||
} else if (eff & EFFECT_SLIDE_BOTTOM) {
|
||||
if (eff & EFFECT_SLIDE_FROM)
|
||||
if (eff & EFFECT_SLIDE_FROM) {
|
||||
yoffsetDyn = (int32_t) getHeight() * scaleY;
|
||||
else
|
||||
} else {
|
||||
yoffsetDyn = screenheight;
|
||||
}
|
||||
} else if (eff & EFFECT_SLIDE_RIGHT) {
|
||||
if (eff & EFFECT_SLIDE_FROM)
|
||||
if (eff & EFFECT_SLIDE_FROM) {
|
||||
xoffsetDyn = (int32_t) getWidth() * scaleX;
|
||||
else
|
||||
} else {
|
||||
xoffsetDyn = screenwidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((eff & EFFECT_FADE) && amount > 0) {
|
||||
@ -178,8 +183,9 @@ void GuiElement::resetEffects() {
|
||||
}
|
||||
|
||||
void GuiElement::updateEffects() {
|
||||
if (!this->isVisible() && parentElement)
|
||||
if (!this->isVisible() && parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (effects & (EFFECT_SLIDE_IN | EFFECT_SLIDE_OUT | EFFECT_SLIDE_FROM)) {
|
||||
if (effects & EFFECT_SLIDE_IN) {
|
||||
|
@ -22,8 +22,9 @@ GuiFrame::GuiFrame(GuiFrame *p) {
|
||||
height = 0;
|
||||
dim = false;
|
||||
|
||||
if (parent)
|
||||
if (parent) {
|
||||
parent->append(this);
|
||||
}
|
||||
}
|
||||
|
||||
GuiFrame::GuiFrame(float w, float h, GuiFrame *p) {
|
||||
@ -32,20 +33,23 @@ GuiFrame::GuiFrame(float w, float h, GuiFrame *p) {
|
||||
height = h;
|
||||
dim = false;
|
||||
|
||||
if (parent)
|
||||
if (parent) {
|
||||
parent->append(this);
|
||||
}
|
||||
}
|
||||
|
||||
GuiFrame::~GuiFrame() {
|
||||
closing(this);
|
||||
|
||||
if (parent)
|
||||
if (parent) {
|
||||
parent->remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiFrame::append(GuiElement *e) {
|
||||
if (e == NULL)
|
||||
if (e == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
remove(e);
|
||||
elements.push_back(e);
|
||||
@ -53,8 +57,9 @@ void GuiFrame::append(GuiElement *e) {
|
||||
}
|
||||
|
||||
void GuiFrame::insert(GuiElement *e, uint32_t index) {
|
||||
if (e == NULL || (index >= elements.size()))
|
||||
if (e == NULL || (index >= elements.size())) {
|
||||
return;
|
||||
}
|
||||
|
||||
remove(e);
|
||||
elements.insert(elements.begin() + index, e);
|
||||
@ -62,8 +67,9 @@ void GuiFrame::insert(GuiElement *e, uint32_t index) {
|
||||
}
|
||||
|
||||
void GuiFrame::remove(GuiElement *e) {
|
||||
if (e == NULL)
|
||||
if (e == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < elements.size(); ++i) {
|
||||
if (e == elements[i]) {
|
||||
@ -86,8 +92,9 @@ void GuiFrame::dimBackground(bool d) {
|
||||
}
|
||||
|
||||
GuiElement *GuiFrame::getGuiElementAt(uint32_t index) const {
|
||||
if (index >= elements.size())
|
||||
if (index >= elements.size()) {
|
||||
return NULL;
|
||||
}
|
||||
return elements[index];
|
||||
}
|
||||
|
||||
@ -140,8 +147,9 @@ int32_t GuiFrame::getSelected() {
|
||||
}
|
||||
|
||||
void GuiFrame::draw(CVideo *v) {
|
||||
if (!this->isVisible() && parentElement)
|
||||
if (!this->isVisible() && parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentElement && dim == true) {
|
||||
//GXColor dimColor = (GXColor){0, 0, 0, 0x70};
|
||||
@ -157,8 +165,9 @@ void GuiFrame::draw(CVideo *v) {
|
||||
}
|
||||
|
||||
void GuiFrame::updateEffects() {
|
||||
if (!this->isVisible() && parentElement)
|
||||
if (!this->isVisible() && parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
GuiElement::updateEffects();
|
||||
|
||||
@ -171,8 +180,9 @@ void GuiFrame::updateEffects() {
|
||||
}
|
||||
|
||||
void GuiFrame::process() {
|
||||
if (!this->isVisible() && parentElement)
|
||||
if (!this->isVisible() && parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
GuiElement::process();
|
||||
|
||||
@ -185,8 +195,9 @@ void GuiFrame::process() {
|
||||
}
|
||||
|
||||
void GuiFrame::update(GuiController *c) {
|
||||
if (isStateSet(STATE_DISABLED) && parentElement)
|
||||
if (isStateSet(STATE_DISABLED) && parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
//! update appended items next frame
|
||||
uint32_t size = elements.size();
|
||||
|
@ -39,8 +39,9 @@ GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color &c, int32_t type) {
|
||||
|
||||
colorVtxs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, colorCount * ColorShader::cuColorAttrSize);
|
||||
if (colorVtxs) {
|
||||
for (uint32_t i = 0; i < colorCount; i++)
|
||||
for (uint32_t i = 0; i < colorCount; i++) {
|
||||
setImageColor(c, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,8 +49,9 @@ GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color *c, uint32_t color_count
|
||||
internalInit(w, h);
|
||||
imgType = type;
|
||||
colorCount = ColorShader::cuColorVtxsSize / ColorShader::cuColorAttrSize;
|
||||
if (colorCount < color_count)
|
||||
if (colorCount < color_count) {
|
||||
colorCount = color_count;
|
||||
}
|
||||
|
||||
colorVtxs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, colorCount * ColorShader::cuColorAttrSize);
|
||||
if (colorVtxs) {
|
||||
@ -105,10 +107,11 @@ void GuiImage::setImageData(GuiImageData *img) {
|
||||
}
|
||||
|
||||
GX2Color GuiImage::getPixel(int32_t x, int32_t y) {
|
||||
if (!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight())
|
||||
if (!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) {
|
||||
return (GX2Color) {
|
||||
0, 0, 0, 0
|
||||
};
|
||||
}
|
||||
|
||||
uint32_t pitch = imageData->getTexture()->surface.pitch;
|
||||
uint32_t *imagePtr = (uint32_t *) imageData->getTexture()->surface.image;
|
||||
@ -123,8 +126,9 @@ GX2Color GuiImage::getPixel(int32_t x, int32_t y) {
|
||||
}
|
||||
|
||||
void GuiImage::setPixel(int32_t x, int32_t y, const GX2Color &color) {
|
||||
if (!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight())
|
||||
if (!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint32_t pitch = imageData->getTexture()->surface.pitch;
|
||||
@ -186,8 +190,9 @@ void GuiImage::setPrimitiveVertex(int32_t prim, const float *posVtx, const float
|
||||
}
|
||||
|
||||
void GuiImage::draw(CVideo *pVideo) {
|
||||
if (!this->isVisible() || tileVertical == 0 || tileHorizontal == 0)
|
||||
if (!this->isVisible() || tileVertical == 0 || tileHorizontal == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float currScaleX = getScaleX();
|
||||
float currScaleY = getScaleY();
|
||||
|
@ -42,8 +42,9 @@ GuiImageAsync::~GuiImageAsync() {
|
||||
while (pInUse == this)
|
||||
OSSleepTicks(OSMicrosecondsToTicks(1000));
|
||||
|
||||
if (imgData)
|
||||
if (imgData) {
|
||||
delete imgData;
|
||||
}
|
||||
|
||||
//threadExit();
|
||||
}
|
||||
@ -74,8 +75,9 @@ void GuiImageAsync::clearQueue() {
|
||||
|
||||
void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
|
||||
while (!bExitRequested) {
|
||||
if (imageQueue.empty() && !bExitRequested)
|
||||
if (imageQueue.empty() && !bExitRequested) {
|
||||
pThread->suspendThread();
|
||||
}
|
||||
|
||||
if (!imageQueue.empty() && !bExitRequested) {
|
||||
pMutex->lock();
|
||||
@ -83,8 +85,9 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
|
||||
imageQueue.erase(imageQueue.begin());
|
||||
pMutex->unlock();
|
||||
|
||||
if (!pInUse)
|
||||
if (!pInUse) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (pInUse->imgBuffer && pInUse->imgBufferSize) {
|
||||
@ -106,8 +109,9 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
|
||||
blocksize = filesize - done;
|
||||
}
|
||||
readBytes = file.read(buffer + done, blocksize);
|
||||
if (readBytes <= 0)
|
||||
if (readBytes <= 0) {
|
||||
break;
|
||||
}
|
||||
done += readBytes;
|
||||
}
|
||||
if (done == filesize) {
|
||||
|
@ -71,8 +71,9 @@ void GuiImageData::releaseData(void) {
|
||||
}
|
||||
|
||||
void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMode textureClamp, GX2SurfaceFormat textureFormat) {
|
||||
if (!img || (imgSize < 8))
|
||||
if (!img || (imgSize < 8)) {
|
||||
return;
|
||||
}
|
||||
|
||||
releaseData();
|
||||
gdImagePtr gdImg = 0;
|
||||
@ -95,8 +96,9 @@ void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMod
|
||||
gdImg = gdImageCreateFromTgaPtr(imgSize, (uint8_t *) img);
|
||||
}
|
||||
|
||||
if (gdImg == 0)
|
||||
if (gdImg == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t width = (gdImageSX(gdImg));
|
||||
uint32_t height = (gdImageSY(gdImg));
|
||||
@ -162,7 +164,7 @@ void GuiImageData::gdImageToUnormR8G8B8A8(gdImagePtr gdImg, uint32_t *imgBuffer,
|
||||
uint32_t pixel = gdImageGetPixel(gdImg, x, y);
|
||||
|
||||
uint8_t a = 254 - 2 * ((uint8_t) gdImageAlpha(gdImg, pixel));
|
||||
if (a == 254) a++;
|
||||
if (a == 254) { a++; }
|
||||
|
||||
uint8_t r = gdImageRed(gdImg, pixel);
|
||||
uint8_t g = gdImageGreen(gdImg, pixel);
|
||||
|
@ -74,8 +74,9 @@ GuiParticleImage::~GuiParticleImage() {
|
||||
}
|
||||
|
||||
void GuiParticleImage::draw(CVideo *pVideo) {
|
||||
if (!this->isVisible())
|
||||
if (!this->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
float currScaleX = getScaleX();
|
||||
|
@ -93,8 +93,9 @@ void GuiScrollbar::ScrollOneDown() {
|
||||
}
|
||||
|
||||
void GuiScrollbar::OnUpButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
|
||||
if (ScrollState < ScrollSpeed)
|
||||
if (ScrollState < ScrollSpeed) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollOneUp();
|
||||
|
||||
@ -103,8 +104,9 @@ void GuiScrollbar::OnUpButtonClick(GuiButton *button, const GuiController *contr
|
||||
}
|
||||
|
||||
void GuiScrollbar::OnDownButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
|
||||
if (ScrollState < ScrollSpeed)
|
||||
if (ScrollState < ScrollSpeed) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollOneDown();
|
||||
|
||||
@ -148,32 +150,36 @@ void GuiScrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *contr
|
||||
}
|
||||
|
||||
void GuiScrollbar::SetPageSize(int32_t size) {
|
||||
if (PageSize == size)
|
||||
if (PageSize == size) {
|
||||
return;
|
||||
}
|
||||
|
||||
PageSize = size;
|
||||
listChanged(SelItem, SelInd);
|
||||
}
|
||||
|
||||
void GuiScrollbar::SetSelectedItem(int32_t pos) {
|
||||
if (SelItem == pos)
|
||||
if (SelItem == pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
SelItem = LIMIT(pos, 0, EntrieCount - 1);
|
||||
listChanged(SelItem, SelInd);
|
||||
}
|
||||
|
||||
void GuiScrollbar::SetSelectedIndex(int32_t pos) {
|
||||
if (SelInd == pos)
|
||||
if (SelInd == pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
SelInd = pos;
|
||||
listChanged(SelItem, SelInd);
|
||||
}
|
||||
|
||||
void GuiScrollbar::SetEntrieCount(int32_t cnt) {
|
||||
if (EntrieCount == cnt)
|
||||
if (EntrieCount == cnt) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntrieCount = cnt;
|
||||
listChanged(SelItem, SelInd);
|
||||
@ -182,10 +188,11 @@ void GuiScrollbar::SetEntrieCount(int32_t cnt) {
|
||||
void GuiScrollbar::setScrollboxPosition(int32_t SelItem, int32_t SelInd) {
|
||||
int32_t position = MaxHeight - (MaxHeight - MinHeight) * (SelInd + SelItem) / (EntrieCount - 1);
|
||||
|
||||
if (position < MinHeight || (SelInd + SelItem >= EntrieCount - 1))
|
||||
if (position < MinHeight || (SelInd + SelItem >= EntrieCount - 1)) {
|
||||
position = MinHeight;
|
||||
else if (position > MaxHeight || (SelInd + SelItem) == 0)
|
||||
} else if (position > MaxHeight || (SelInd + SelItem) == 0) {
|
||||
position = MaxHeight;
|
||||
}
|
||||
|
||||
scrollbarBoxBtn->setPosition(0, position);
|
||||
}
|
||||
@ -202,8 +209,9 @@ void GuiScrollbar::draw(CVideo *video) {
|
||||
}
|
||||
|
||||
void GuiScrollbar::update(GuiController *t) {
|
||||
if (this->isStateSet(STATE_DISABLED))
|
||||
if (this->isStateSet(STATE_DISABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
arrowUpBtn->update(t);
|
||||
arrowDownBtn->update(t);
|
||||
|
@ -84,7 +84,7 @@ void GuiSelectBox::SelectValue(uint32_t value) {
|
||||
topValueText.setText(text.c_str());
|
||||
|
||||
std::string real_value = buttonToValue[valueButtons[value].valueButton];
|
||||
if (real_value.compare(std::string()) == 0) real_value = "<error>";
|
||||
if (real_value.compare(std::string()) == 0) { real_value = "<error>"; }
|
||||
|
||||
valueChanged(this, real_value);
|
||||
ShowHideValues(false);
|
||||
@ -114,11 +114,11 @@ void GuiSelectBox::OnDPADClick(GuiButton *button, const GuiController *controlle
|
||||
} else {
|
||||
}
|
||||
} else if (trigger == &buttonUpTrigger) {
|
||||
if (selected > 0) selected--;
|
||||
if (selected > 0) { selected--; }
|
||||
bSelectedChanged = true;
|
||||
} else if (trigger == &buttonDownTrigger) {
|
||||
selected++;
|
||||
if (selected >= valueButtons.size()) selected = valueButtons.size() - 1;
|
||||
if (selected >= valueButtons.size()) { selected = valueButtons.size() - 1; }
|
||||
bSelectedChanged = true;
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +70,9 @@ bool GuiSound::Load(const uint8_t *snd, int32_t len) {
|
||||
voice = -1;
|
||||
}
|
||||
|
||||
if (!snd)
|
||||
if (!snd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//! find next free decoder
|
||||
for (int32_t i = 0; i < MAX_DECODERS; i++) {
|
||||
@ -98,8 +99,9 @@ void GuiSound::Play() {
|
||||
Stop();
|
||||
|
||||
Voice *v = SoundHandler::instance()->getVoice(voice);
|
||||
if (v)
|
||||
if (v) {
|
||||
v->setState(Voice::STATE_START);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -107,8 +109,9 @@ void GuiSound::Play() {
|
||||
void GuiSound::Stop() {
|
||||
Voice *v = SoundHandler::instance()->getVoice(voice);
|
||||
if (v) {
|
||||
if ((v->getState() != Voice::STATE_STOP) && (v->getState() != Voice::STATE_STOPPED))
|
||||
if ((v->getState() != Voice::STATE_STOP) && (v->getState() != Voice::STATE_STOPPED)) {
|
||||
v->setState(Voice::STATE_STOP);
|
||||
}
|
||||
|
||||
while (v->getState() != Voice::STATE_STOPPED)
|
||||
OSSleepTicks(OSMicrosecondsToTicks(1000));
|
||||
@ -125,21 +128,25 @@ void GuiSound::Stop() {
|
||||
}
|
||||
|
||||
void GuiSound::Pause() {
|
||||
if (!IsPlaying())
|
||||
if (!IsPlaying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Voice *v = SoundHandler::instance()->getVoice(voice);
|
||||
if (v)
|
||||
if (v) {
|
||||
v->setState(Voice::STATE_STOP);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiSound::Resume() {
|
||||
if (IsPlaying())
|
||||
if (IsPlaying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Voice *v = SoundHandler::instance()->getVoice(voice);
|
||||
if (v)
|
||||
if (v) {
|
||||
v->setState(Voice::STATE_START);
|
||||
}
|
||||
}
|
||||
|
||||
bool GuiSound::IsPlaying() {
|
||||
@ -151,20 +158,23 @@ bool GuiSound::IsPlaying() {
|
||||
}
|
||||
|
||||
void GuiSound::SetVolume(uint32_t vol) {
|
||||
if (vol > 100)
|
||||
if (vol > 100) {
|
||||
vol = 100;
|
||||
}
|
||||
|
||||
uint32_t volumeConv = ((0x8000 * vol) / 100) << 16;
|
||||
|
||||
Voice *v = SoundHandler::instance()->getVoice(voice);
|
||||
if (v)
|
||||
if (v) {
|
||||
v->setVolume(volumeConv);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiSound::SetLoop(bool l) {
|
||||
SoundDecoder *decoder = SoundHandler::instance()->getDecoder(voice);
|
||||
if (decoder)
|
||||
if (decoder) {
|
||||
decoder->SetLoop(l);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiSound::Rewind() {
|
||||
|
@ -80,8 +80,9 @@ GuiText::GuiText(const char *t, int32_t s, const glm::vec4 &c) {
|
||||
|
||||
if (t) {
|
||||
text = FreeTypeGX::charToWideChar(t);
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
textWidth = font->getWidth(text, currentSize);
|
||||
}
|
||||
@ -110,8 +111,9 @@ GuiText::GuiText(const wchar_t *t, int32_t s, const glm::vec4 &c) {
|
||||
|
||||
if (t) {
|
||||
text = new(std::nothrow) wchar_t[wcslen(t) + 1];
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
wcscpy(text, t);
|
||||
|
||||
@ -145,8 +147,9 @@ GuiText::GuiText(const char *t) {
|
||||
|
||||
if (t) {
|
||||
text = FreeTypeGX::charToWideChar(t);
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
textWidth = font->getWidth(text, currentSize);
|
||||
}
|
||||
@ -157,16 +160,18 @@ GuiText::GuiText(const char *t) {
|
||||
* Destructor for the GuiText class.
|
||||
*/
|
||||
GuiText::~GuiText() {
|
||||
if (text)
|
||||
if (text) {
|
||||
delete[] text;
|
||||
}
|
||||
text = NULL;
|
||||
|
||||
clearDynamicText();
|
||||
}
|
||||
|
||||
void GuiText::setText(const char *t) {
|
||||
if (text)
|
||||
if (text) {
|
||||
delete[] text;
|
||||
}
|
||||
text = NULL;
|
||||
|
||||
clearDynamicText();
|
||||
@ -176,8 +181,9 @@ void GuiText::setText(const char *t) {
|
||||
|
||||
if (t) {
|
||||
text = FreeTypeGX::charToWideChar(t);
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
textWidth = font->getWidth(text, currentSize);
|
||||
}
|
||||
@ -198,14 +204,16 @@ void GuiText::setTextf(const char *format, ...) {
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
if (tmp)
|
||||
if (tmp) {
|
||||
delete[] tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GuiText::setText(const wchar_t *t) {
|
||||
if (text)
|
||||
if (text) {
|
||||
delete[] text;
|
||||
}
|
||||
text = NULL;
|
||||
|
||||
clearDynamicText();
|
||||
@ -215,8 +223,9 @@ void GuiText::setText(const wchar_t *t) {
|
||||
|
||||
if (t) {
|
||||
text = new(std::nothrow) wchar_t[wcslen(t) + 1];
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
wcscpy(text, t);
|
||||
|
||||
@ -226,8 +235,9 @@ void GuiText::setText(const wchar_t *t) {
|
||||
|
||||
void GuiText::clearDynamicText() {
|
||||
for (uint32_t i = 0; i < textDyn.size(); i++) {
|
||||
if (textDyn[i])
|
||||
if (textDyn[i]) {
|
||||
delete[] textDyn[i];
|
||||
}
|
||||
}
|
||||
textDyn.clear();
|
||||
textDynWidth.clear();
|
||||
@ -275,15 +285,17 @@ void GuiText::setBlurGlowColor(float blur, const glm::vec4 &c) {
|
||||
}
|
||||
|
||||
int32_t GuiText::getTextWidth(int32_t ind) {
|
||||
if (ind < 0 || ind >= (int32_t) textDyn.size())
|
||||
if (ind < 0 || ind >= (int32_t) textDyn.size()) {
|
||||
return this->getTextWidth();
|
||||
}
|
||||
|
||||
return font->getWidth(textDyn[ind], currentSize);
|
||||
}
|
||||
|
||||
const wchar_t *GuiText::getDynText(int32_t ind) {
|
||||
if (ind < 0 || ind >= (int32_t) textDyn.size())
|
||||
if (ind < 0 || ind >= (int32_t) textDyn.size()) {
|
||||
return text;
|
||||
}
|
||||
|
||||
return textDyn[ind];
|
||||
}
|
||||
@ -292,8 +304,9 @@ const wchar_t *GuiText::getDynText(int32_t ind) {
|
||||
* Change font
|
||||
*/
|
||||
bool GuiText::setFont(FreeTypeGX *f) {
|
||||
if (!f)
|
||||
if (!f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
font = f;
|
||||
textWidth = font->getWidth(text, currentSize);
|
||||
@ -301,12 +314,14 @@ bool GuiText::setFont(FreeTypeGX *f) {
|
||||
}
|
||||
|
||||
std::string GuiText::toUTF8(void) const {
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
char *pUtf8 = FreeTypeGX::wideCharToUTF8(text);
|
||||
if (!pUtf8)
|
||||
if (!pUtf8) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string strOutput(pUtf8);
|
||||
|
||||
@ -387,8 +402,9 @@ void GuiText::scrollText(uint32_t frameCount) {
|
||||
int32_t ch = textScrollPos;
|
||||
int32_t pos = textDyn.size() - 1;
|
||||
|
||||
if (!textDyn[pos])
|
||||
if (!textDyn[pos]) {
|
||||
textDyn[pos] = new(std::nothrow) wchar_t[maxWidth];
|
||||
}
|
||||
|
||||
if (!textDyn[pos]) {
|
||||
textDyn.resize(pos);
|
||||
@ -407,8 +423,9 @@ void GuiText::scrollText(uint32_t frameCount) {
|
||||
currentWidth += font->getCharWidth(L' ', currentSize, L' ');
|
||||
ch = 0;
|
||||
|
||||
if (currentWidth >= maxWidth)
|
||||
if (currentWidth >= maxWidth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
textDyn[pos][i] = text[ch];
|
||||
@ -420,7 +437,7 @@ void GuiText::scrollText(uint32_t frameCount) {
|
||||
}
|
||||
|
||||
void GuiText::wrapText() {
|
||||
if (textDyn.size() > 0) return;
|
||||
if (textDyn.size() > 0) { return; }
|
||||
|
||||
int32_t i = 0;
|
||||
int32_t ch = 0;
|
||||
@ -456,8 +473,9 @@ void GuiText::wrapText() {
|
||||
}
|
||||
|
||||
if (linenum + 1 == linestodraw && text[ch + 1] != 0x0000) {
|
||||
if (i < 2)
|
||||
if (i < 2) {
|
||||
i = 2;
|
||||
}
|
||||
|
||||
textDyn[linenum][i - 2] = '.';
|
||||
textDyn[linenum][i - 1] = '.';
|
||||
@ -482,11 +500,13 @@ void GuiText::wrapText() {
|
||||
* Draw the text on screen
|
||||
*/
|
||||
void GuiText::draw(CVideo *pVideo) {
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isVisible())
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
color[3] = getAlpha();
|
||||
blurGlowColor[3] = blurAlpha * getAlpha();
|
||||
@ -499,8 +519,9 @@ void GuiText::draw(CVideo *pVideo) {
|
||||
if (newSize != currentSize) {
|
||||
currentSize = normal_size;
|
||||
|
||||
if (text)
|
||||
if (text) {
|
||||
textWidth = font->getWidth(text, normal_size);
|
||||
}
|
||||
}
|
||||
|
||||
float x_pos = getCenterX() * finalRenderingScale;
|
||||
@ -508,42 +529,49 @@ void GuiText::draw(CVideo *pVideo) {
|
||||
|
||||
if (maxWidth > 0 && maxWidth <= textWidth) {
|
||||
if (wrapMode == DOTTED) { // text dotted
|
||||
if (textDyn.size() == 0)
|
||||
if (textDyn.size() == 0) {
|
||||
makeDottedText();
|
||||
}
|
||||
|
||||
if (textDynWidth.size() != textDyn.size()) {
|
||||
textDynWidth.resize(textDyn.size());
|
||||
|
||||
for (uint32_t i = 0; i < textDynWidth.size(); i++)
|
||||
for (uint32_t i = 0; i < textDynWidth.size(); i++) {
|
||||
textDynWidth[i] = font->getWidth(textDyn[i], newSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (textDyn.size() > 0)
|
||||
if (textDyn.size() > 0) {
|
||||
font->drawText(pVideo, x_pos, y_pos, getDepth(), textDyn[textDyn.size() - 1], newSize, color, alignment, textDynWidth[textDyn.size() - 1], defaultBlur, blurGlowIntensity, blurGlowColor, finalRenderingScale);
|
||||
}
|
||||
} else if (wrapMode == SCROLL_HORIZONTAL) {
|
||||
scrollText(pVideo->getFrameCount());
|
||||
|
||||
if (textDyn.size() > 0)
|
||||
if (textDyn.size() > 0) {
|
||||
font->drawText(pVideo, x_pos, y_pos, getDepth(), textDyn[textDyn.size() - 1], newSize, color, alignment, maxWidth * finalRenderingScale, defaultBlur, blurGlowIntensity, blurGlowColor, finalRenderingScale);
|
||||
}
|
||||
|
||||
} else if (wrapMode == WRAP) {
|
||||
int32_t lineheight = newSize + 6;
|
||||
int32_t yoffset = 0;
|
||||
int32_t voffset = 0;
|
||||
|
||||
if (textDyn.size() == 0)
|
||||
if (textDyn.size() == 0) {
|
||||
wrapText();
|
||||
}
|
||||
|
||||
if (textDynWidth.size() != textDyn.size()) {
|
||||
textDynWidth.resize(textDyn.size());
|
||||
|
||||
for (uint32_t i = 0; i < textDynWidth.size(); i++)
|
||||
for (uint32_t i = 0; i < textDynWidth.size(); i++) {
|
||||
textDynWidth[i] = font->getWidth(textDyn[i], newSize);
|
||||
}
|
||||
}
|
||||
|
||||
if (alignment & ALIGN_MIDDLE)
|
||||
if (alignment & ALIGN_MIDDLE) {
|
||||
voffset = (lineheight * (textDyn.size() - 1)) >> 1;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < textDyn.size(); i++) {
|
||||
font->drawText(pVideo, x_pos, y_pos + voffset + yoffset, getDepth(), textDyn[i], newSize, color, alignment, textDynWidth[i], defaultBlur, blurGlowIntensity, blurGlowColor, finalRenderingScale);
|
||||
|
@ -125,8 +125,9 @@ bool GuiTrigger::released(const GuiController *controller) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (clicked(controller) || held(controller))
|
||||
if (clicked(controller) || held(controller)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bResult = false;
|
||||
|
||||
|
@ -40,14 +40,16 @@ BufferCircle::~BufferCircle() {
|
||||
}
|
||||
|
||||
void BufferCircle::SetBufferBlockSize(int32_t size) {
|
||||
if (size < 0)
|
||||
if (size < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferBlockSize = size;
|
||||
|
||||
for (int32_t i = 0; i < Size(); i++) {
|
||||
if (SoundBuffer[i] != NULL)
|
||||
if (SoundBuffer[i] != NULL) {
|
||||
free(SoundBuffer[i]);
|
||||
}
|
||||
|
||||
SoundBuffer[i] = (uint8_t *) memalign(32, ALIGN32(BufferBlockSize));
|
||||
BufferSize[i] = 0;
|
||||
@ -66,21 +68,24 @@ void BufferCircle::Resize(int32_t size) {
|
||||
BufferReady.resize(size);
|
||||
|
||||
for (int32_t i = oldSize; i < Size(); i++) {
|
||||
if (BufferBlockSize > 0)
|
||||
if (BufferBlockSize > 0) {
|
||||
SoundBuffer[i] = (uint8_t *) memalign(32, ALIGN32(BufferBlockSize));
|
||||
else
|
||||
} else {
|
||||
SoundBuffer[i] = NULL;
|
||||
}
|
||||
BufferSize[i] = 0;
|
||||
BufferReady[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void BufferCircle::RemoveBuffer(int32_t pos) {
|
||||
if (!Valid(pos))
|
||||
if (!Valid(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SoundBuffer[pos] != NULL)
|
||||
if (SoundBuffer[pos] != NULL) {
|
||||
free(SoundBuffer[pos]);
|
||||
}
|
||||
|
||||
SoundBuffer.erase(SoundBuffer.begin() + pos);
|
||||
BufferSize.erase(BufferSize.begin() + pos);
|
||||
@ -97,8 +102,9 @@ void BufferCircle::ClearBuffer() {
|
||||
|
||||
void BufferCircle::FreeBuffer() {
|
||||
for (int32_t i = 0; i < Size(); i++) {
|
||||
if (SoundBuffer[i] != NULL)
|
||||
if (SoundBuffer[i] != NULL) {
|
||||
free(SoundBuffer[i]);
|
||||
}
|
||||
|
||||
SoundBuffer[i] = NULL;
|
||||
BufferSize[i] = 0;
|
||||
@ -114,15 +120,17 @@ void BufferCircle::LoadNext() {
|
||||
}
|
||||
|
||||
void BufferCircle::SetBufferReady(int32_t pos, bool state) {
|
||||
if (!Valid(pos))
|
||||
if (!Valid(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferReady[pos] = state;
|
||||
}
|
||||
|
||||
void BufferCircle::SetBufferSize(int32_t pos, int32_t size) {
|
||||
if (!Valid(pos))
|
||||
if (!Valid(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferSize[pos] = size;
|
||||
}
|
||||
|
@ -43,8 +43,9 @@ Mp3Decoder::Mp3Decoder(const char *filepath)
|
||||
mad_frame_init(&Frame);
|
||||
mad_synth_init(&Synth);
|
||||
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return;
|
||||
}
|
||||
|
||||
OpenFile();
|
||||
}
|
||||
@ -58,8 +59,9 @@ Mp3Decoder::Mp3Decoder(const uint8_t *snd, int32_t len)
|
||||
mad_frame_init(&Frame);
|
||||
mad_synth_init(&Synth);
|
||||
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return;
|
||||
}
|
||||
|
||||
OpenFile();
|
||||
}
|
||||
@ -73,8 +75,9 @@ Mp3Decoder::~Mp3Decoder() {
|
||||
mad_frame_finish(&Frame);
|
||||
mad_stream_finish(&Stream);
|
||||
|
||||
if (ReadBuffer)
|
||||
if (ReadBuffer) {
|
||||
free(ReadBuffer);
|
||||
}
|
||||
ReadBuffer = NULL;
|
||||
}
|
||||
|
||||
@ -82,8 +85,9 @@ void Mp3Decoder::OpenFile() {
|
||||
GuardPtr = NULL;
|
||||
ReadBuffer = (uint8_t *) memalign(32, SoundBlockSize * SoundBlocks);
|
||||
if (!ReadBuffer) {
|
||||
if (file_fd)
|
||||
if (file_fd) {
|
||||
delete file_fd;
|
||||
}
|
||||
file_fd = NULL;
|
||||
return;
|
||||
}
|
||||
@ -91,8 +95,9 @@ void Mp3Decoder::OpenFile() {
|
||||
uint8_t dummybuff[4096];
|
||||
int32_t ret = Read(dummybuff, 4096, 0);
|
||||
if (ret <= 0) {
|
||||
if (file_fd)
|
||||
if (file_fd) {
|
||||
delete file_fd;
|
||||
}
|
||||
file_fd = NULL;
|
||||
return;
|
||||
}
|
||||
@ -113,39 +118,45 @@ int32_t Mp3Decoder::Rewind() {
|
||||
SynthPos = 0;
|
||||
GuardPtr = NULL;
|
||||
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return SoundDecoder::Rewind();
|
||||
}
|
||||
|
||||
static inline int16_t FixedToShort(mad_fixed_t Fixed) {
|
||||
/* Clipping */
|
||||
if (Fixed >= MAD_F_ONE)
|
||||
if (Fixed >= MAD_F_ONE) {
|
||||
return (SHRT_MAX);
|
||||
if (Fixed <= -MAD_F_ONE)
|
||||
}
|
||||
if (Fixed <= -MAD_F_ONE) {
|
||||
return (-SHRT_MAX);
|
||||
}
|
||||
|
||||
Fixed = Fixed >> (MAD_F_FRACBITS - 15);
|
||||
return ((int16_t) Fixed);
|
||||
}
|
||||
|
||||
int32_t Mp3Decoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) {
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (Format == (FORMAT_PCM_16_BIT | CHANNELS_STEREO))
|
||||
if (Format == (FORMAT_PCM_16_BIT | CHANNELS_STEREO)) {
|
||||
buffer_size &= ~0x0003;
|
||||
else
|
||||
} else {
|
||||
buffer_size &= ~0x0001;
|
||||
}
|
||||
|
||||
uint8_t *write_pos = buffer;
|
||||
uint8_t *write_end = buffer + buffer_size;
|
||||
|
||||
while (1) {
|
||||
while (SynthPos < Synth.pcm.length) {
|
||||
if (write_pos >= write_end)
|
||||
if (write_pos >= write_end) {
|
||||
return write_pos - buffer;
|
||||
}
|
||||
|
||||
*((int16_t *) write_pos) = FixedToShort(Synth.pcm.samples[0][SynthPos]);
|
||||
write_pos += 2;
|
||||
@ -182,13 +193,15 @@ int32_t Mp3Decoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) {
|
||||
|
||||
if (mad_frame_decode(&Frame, &Stream)) {
|
||||
if (MAD_RECOVERABLE(Stream.error)) {
|
||||
if (Stream.error != MAD_ERROR_LOSTSYNC || !GuardPtr)
|
||||
if (Stream.error != MAD_ERROR_LOSTSYNC || !GuardPtr) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (Stream.error != MAD_ERROR_BUFLEN)
|
||||
if (Stream.error != MAD_ERROR_BUFLEN) {
|
||||
return -1;
|
||||
else if (Stream.error == MAD_ERROR_BUFLEN && GuardPtr)
|
||||
} else if (Stream.error == MAD_ERROR_BUFLEN && GuardPtr) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,9 @@ OggDecoder::OggDecoder(const char *filepath)
|
||||
: SoundDecoder(filepath) {
|
||||
SoundType = SOUND_OGG;
|
||||
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return;
|
||||
}
|
||||
|
||||
OpenFile();
|
||||
}
|
||||
@ -68,8 +69,9 @@ OggDecoder::OggDecoder(const uint8_t *snd, int32_t len)
|
||||
: SoundDecoder(snd, len) {
|
||||
SoundType = SOUND_OGG;
|
||||
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return;
|
||||
}
|
||||
|
||||
OpenFile();
|
||||
}
|
||||
@ -79,8 +81,9 @@ OggDecoder::~OggDecoder() {
|
||||
while (Decoding)
|
||||
OSSleepTicks(OSMicrosecondsToTicks(100));
|
||||
|
||||
if (file_fd)
|
||||
if (file_fd) {
|
||||
ov_clear(&ogg_file);
|
||||
}
|
||||
}
|
||||
|
||||
void OggDecoder::OpenFile() {
|
||||
@ -103,8 +106,9 @@ void OggDecoder::OpenFile() {
|
||||
}
|
||||
|
||||
int32_t OggDecoder::Rewind() {
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ret = ov_time_seek(&ogg_file, 0);
|
||||
CurPos = 0;
|
||||
@ -114,15 +118,17 @@ int32_t OggDecoder::Rewind() {
|
||||
}
|
||||
|
||||
int32_t OggDecoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) {
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t bitstream = 0;
|
||||
|
||||
int32_t read = (int32_t) ov_read(&ogg_file, (char *) buffer, (int) buffer_size, (int *) &bitstream);
|
||||
|
||||
if (read > 0)
|
||||
if (read > 0) {
|
||||
CurPos += read;
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
@ -51,12 +51,14 @@ SoundDecoder::~SoundDecoder() {
|
||||
Lock();
|
||||
Unlock();
|
||||
|
||||
if (file_fd)
|
||||
if (file_fd) {
|
||||
delete file_fd;
|
||||
}
|
||||
file_fd = NULL;
|
||||
|
||||
if (ResampleBuffer)
|
||||
if (ResampleBuffer) {
|
||||
free(ResampleBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t SoundDecoder::Seek(int32_t pos) {
|
||||
@ -133,8 +135,9 @@ void SoundDecoder::Upsample(int16_t *src, int16_t *dst, uint32_t nr_src_samples,
|
||||
}
|
||||
|
||||
void SoundDecoder::Decode() {
|
||||
if (!file_fd || ExitRequested || EndOfFile)
|
||||
if (!file_fd || ExitRequested || EndOfFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if we are not at the pre-last buffer (last buffer is playing)
|
||||
uint16_t whichPlaying = SoundBuffer.Which();
|
||||
@ -154,8 +157,9 @@ void SoundDecoder::Decode() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ResampleTo48kHz && !ResampleBuffer)
|
||||
if (ResampleTo48kHz && !ResampleBuffer) {
|
||||
EnableUpsample();
|
||||
}
|
||||
|
||||
while (done < SoundBlockSize) {
|
||||
int32_t ret = Read(&write_buf[done], SoundBlockSize - done, Tell());
|
||||
@ -190,20 +194,23 @@ void SoundDecoder::Decode() {
|
||||
int16_t *monoBuf = (int16_t *) write_buf;
|
||||
done = done >> 1;
|
||||
|
||||
for (int32_t i = 0; i < done; i++)
|
||||
for (int32_t i = 0; i < done; i++) {
|
||||
monoBuf[i] = monoBuf[i << 1];
|
||||
}
|
||||
}
|
||||
|
||||
DCFlushRange(write_buf, done);
|
||||
SoundBuffer.SetBufferSize(whichLoad, done);
|
||||
SoundBuffer.SetBufferReady(whichLoad, true);
|
||||
if (++whichLoad >= SoundBuffer.Size())
|
||||
if (++whichLoad >= SoundBuffer.Size()) {
|
||||
whichLoad = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// check if next in queue needs to be filled as well and do so
|
||||
if (!SoundBuffer.IsBufferReady(whichLoad))
|
||||
if (!SoundBuffer.IsBufferReady(whichLoad)) {
|
||||
Decode();
|
||||
}
|
||||
|
||||
Decoding = false;
|
||||
}
|
||||
|
@ -58,33 +58,39 @@ SoundHandler::~SoundHandler() {
|
||||
}
|
||||
|
||||
void SoundHandler::AddDecoder(int32_t voice, const char *filepath) {
|
||||
if (voice < 0 || voice >= MAX_DECODERS)
|
||||
if (voice < 0 || voice >= MAX_DECODERS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DecoderList[voice] != NULL)
|
||||
if (DecoderList[voice] != NULL) {
|
||||
RemoveDecoder(voice);
|
||||
}
|
||||
|
||||
DecoderList[voice] = GetSoundDecoder(filepath);
|
||||
}
|
||||
|
||||
void SoundHandler::AddDecoder(int32_t voice, const uint8_t *snd, int32_t len) {
|
||||
if (voice < 0 || voice >= MAX_DECODERS)
|
||||
if (voice < 0 || voice >= MAX_DECODERS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DecoderList[voice] != NULL)
|
||||
if (DecoderList[voice] != NULL) {
|
||||
RemoveDecoder(voice);
|
||||
}
|
||||
|
||||
DecoderList[voice] = GetSoundDecoder(snd, len);
|
||||
}
|
||||
|
||||
void SoundHandler::RemoveDecoder(int32_t voice) {
|
||||
if (voice < 0 || voice >= MAX_DECODERS)
|
||||
if (voice < 0 || voice >= MAX_DECODERS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DecoderList[voice] != NULL) {
|
||||
if (voiceList[voice] && voiceList[voice]->getState() != Voice::STATE_STOPPED) {
|
||||
if (voiceList[voice]->getState() != Voice::STATE_STOP)
|
||||
if (voiceList[voice]->getState() != Voice::STATE_STOP) {
|
||||
voiceList[voice]->setState(Voice::STATE_STOP);
|
||||
}
|
||||
|
||||
// it shouldn't take longer than 3 ms actually but we wait up to 20
|
||||
// on application quit the AX frame callback is not called anymore
|
||||
@ -102,8 +108,9 @@ void SoundHandler::RemoveDecoder(int32_t voice) {
|
||||
}
|
||||
|
||||
void SoundHandler::ClearDecoderList() {
|
||||
for (uint32_t i = 0; i < MAX_DECODERS; ++i)
|
||||
for (uint32_t i = 0; i < MAX_DECODERS; ++i) {
|
||||
RemoveDecoder(i);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool CheckMP3Signature(const uint8_t *buffer) {
|
||||
@ -129,8 +136,9 @@ static inline bool CheckMP3Signature(const uint8_t *buffer) {
|
||||
}
|
||||
|
||||
for (int32_t i = 1; i < 13; i++) {
|
||||
if (buffer[0] == MP3_Magic[i][0] && buffer[1] == MP3_Magic[i][1])
|
||||
if (buffer[0] == MP3_Magic[i][0] && buffer[1] == MP3_Magic[i][1]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -139,15 +147,17 @@ static inline bool CheckMP3Signature(const uint8_t *buffer) {
|
||||
SoundDecoder *SoundHandler::GetSoundDecoder(const char *filepath) {
|
||||
uint32_t magic;
|
||||
CFile f(filepath, CFile::ReadOnly);
|
||||
if (f.size() == 0)
|
||||
if (f.size() == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
do {
|
||||
f.read((uint8_t *) &magic, 1);
|
||||
} while (((uint8_t *) &magic)[0] == 0 && f.tell() < f.size());
|
||||
|
||||
if (f.tell() == f.size())
|
||||
if (f.tell() == f.size()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f.seek(f.tell() - 1, SEEK_SET);
|
||||
f.read((uint8_t *) &magic, 4);
|
||||
@ -173,8 +183,9 @@ SoundDecoder *SoundHandler::GetSoundDecoder(const uint8_t *sound, int32_t length
|
||||
counter++;
|
||||
}
|
||||
|
||||
if (counter >= length)
|
||||
if (counter >= length) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t *magic = (uint32_t *) check;
|
||||
|
||||
@ -224,22 +235,27 @@ void SoundHandler::executeThread() {
|
||||
suspendThread();
|
||||
|
||||
for (i = 0; i < MAX_DECODERS; ++i) {
|
||||
if (DecoderList[i] == NULL)
|
||||
if (DecoderList[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Decoding = true;
|
||||
if (DecoderList[i])
|
||||
if (DecoderList[i]) {
|
||||
DecoderList[i]->Lock();
|
||||
if (DecoderList[i])
|
||||
}
|
||||
if (DecoderList[i]) {
|
||||
DecoderList[i]->Decode();
|
||||
if (DecoderList[i])
|
||||
}
|
||||
if (DecoderList[i]) {
|
||||
DecoderList[i]->Unlock();
|
||||
}
|
||||
}
|
||||
Decoding = false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < MAX_DECODERS; ++i)
|
||||
for (uint32_t i = 0; i < MAX_DECODERS; ++i) {
|
||||
voiceList[i]->stop();
|
||||
}
|
||||
|
||||
AXRegisterAppFrameCallback(NULL);
|
||||
AXQuit();
|
||||
@ -304,8 +320,9 @@ void SoundHandler::axFrameCallback(void) {
|
||||
}
|
||||
break;
|
||||
case Voice::STATE_STOP:
|
||||
if (voice->getInternState() != 0)
|
||||
if (voice->getInternState() != 0) {
|
||||
voice->stop();
|
||||
}
|
||||
voice->setState(Voice::STATE_STOPPED);
|
||||
break;
|
||||
}
|
||||
|
@ -34,8 +34,9 @@ WavDecoder::WavDecoder(const char *filepath)
|
||||
SampleRate = 48000;
|
||||
Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT;
|
||||
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return;
|
||||
}
|
||||
|
||||
OpenFile();
|
||||
}
|
||||
@ -46,8 +47,9 @@ WavDecoder::WavDecoder(const uint8_t *snd, int32_t len)
|
||||
SampleRate = 48000;
|
||||
Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT;
|
||||
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return;
|
||||
}
|
||||
|
||||
OpenFile();
|
||||
}
|
||||
@ -96,42 +98,48 @@ void WavDecoder::OpenFile() {
|
||||
Is16Bit = (le16(FmtChunk.bps) == 16);
|
||||
SampleRate = le32(FmtChunk.freq);
|
||||
|
||||
if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 1)
|
||||
if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 1) {
|
||||
Format = CHANNELS_MONO | FORMAT_PCM_8_BIT;
|
||||
else if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 2)
|
||||
} else if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 2) {
|
||||
Format = CHANNELS_MONO | FORMAT_PCM_16_BIT;
|
||||
else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 2)
|
||||
} else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 2) {
|
||||
Format = CHANNELS_STEREO | FORMAT_PCM_8_BIT;
|
||||
else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 4)
|
||||
} else if (le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 4) {
|
||||
Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
void WavDecoder::CloseFile() {
|
||||
if (file_fd)
|
||||
if (file_fd) {
|
||||
delete file_fd;
|
||||
}
|
||||
|
||||
file_fd = NULL;
|
||||
}
|
||||
|
||||
int32_t WavDecoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) {
|
||||
if (!file_fd)
|
||||
if (!file_fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (CurPos >= (int32_t) DataSize)
|
||||
if (CurPos >= (int32_t) DataSize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
file_fd->seek(DataOffset + CurPos, SEEK_SET);
|
||||
|
||||
if (buffer_size > (int32_t) DataSize - CurPos)
|
||||
if (buffer_size > (int32_t) DataSize - CurPos) {
|
||||
buffer_size = DataSize - CurPos;
|
||||
}
|
||||
|
||||
int32_t read = file_fd->read(buffer, buffer_size);
|
||||
if (read > 0) {
|
||||
if (Is16Bit) {
|
||||
read &= ~0x0001;
|
||||
|
||||
for (uint32_t i = 0; i < (uint32_t) (read / sizeof(uint16_t)); ++i)
|
||||
for (uint32_t i = 0; i < (uint32_t) (read / sizeof(uint16_t)); ++i) {
|
||||
((uint16_t *) buffer)[i] = le16(((uint16_t *) buffer)[i]);
|
||||
}
|
||||
}
|
||||
CurPos += read;
|
||||
}
|
||||
|
@ -138,8 +138,9 @@ CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) {
|
||||
uint32_t auxSize, auxAlign;
|
||||
GX2CalcColorBufferAuxInfo(&tvColorBuffer, &auxSize, &auxAlign);
|
||||
tvColorBuffer.aaBuffer = MEM1_alloc(auxSize, auxAlign);
|
||||
if (!tvColorBuffer.aaBuffer)
|
||||
if (!tvColorBuffer.aaBuffer) {
|
||||
tvColorBuffer.aaBuffer = MEM2_alloc(auxSize, auxAlign);
|
||||
}
|
||||
|
||||
tvColorBuffer.aaSize = auxSize;
|
||||
memset(tvColorBuffer.aaBuffer, GX2_AA_BUFFER_CLEAR_VALUE, auxSize);
|
||||
@ -150,8 +151,9 @@ CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) {
|
||||
uint32_t auxSize, auxAlign;
|
||||
GX2CalcColorBufferAuxInfo(&drcColorBuffer, &auxSize, &auxAlign);
|
||||
drcColorBuffer.aaBuffer = MEM1_alloc(auxSize, auxAlign);
|
||||
if (!drcColorBuffer.aaBuffer)
|
||||
if (!drcColorBuffer.aaBuffer) {
|
||||
drcColorBuffer.aaBuffer = MEM2_alloc(auxSize, auxAlign);
|
||||
}
|
||||
drcColorBuffer.aaSize = auxSize;
|
||||
memset(drcColorBuffer.aaBuffer, GX2_AA_BUFFER_CLEAR_VALUE, auxSize);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, drcColorBuffer.aaBuffer, auxSize);
|
||||
@ -224,16 +226,18 @@ CVideo::~CVideo() {
|
||||
MEM2_free(drcContextState);
|
||||
//! free aux buffer
|
||||
if (tvColorBuffer.aaBuffer) {
|
||||
if (((uint32_t) tvColorBuffer.aaBuffer & 0xF0000000) == 0xF0000000)
|
||||
if (((uint32_t) tvColorBuffer.aaBuffer & 0xF0000000) == 0xF0000000) {
|
||||
MEM1_free(tvColorBuffer.aaBuffer);
|
||||
else
|
||||
} else {
|
||||
MEM2_free(tvColorBuffer.aaBuffer);
|
||||
}
|
||||
}
|
||||
if (drcColorBuffer.aaBuffer) {
|
||||
if (((uint32_t) drcColorBuffer.aaBuffer & 0xF0000000) == 0xF0000000)
|
||||
if (((uint32_t) drcColorBuffer.aaBuffer & 0xF0000000) == 0xF0000000) {
|
||||
MEM1_free(drcColorBuffer.aaBuffer);
|
||||
else
|
||||
} else {
|
||||
MEM2_free(drcColorBuffer.aaBuffer);
|
||||
}
|
||||
}
|
||||
//! destroy shaders
|
||||
ColorShader::destroyInstance();
|
||||
|
@ -47,7 +47,7 @@ CursorDrawer::~CursorDrawer() {
|
||||
void CursorDrawer::init_colorVtxs() {
|
||||
if (!this->colorVtxs) {
|
||||
this->colorVtxs = (uint8_t *) memalign(0x40, sizeof(uint8_t) * 16);
|
||||
if (this->colorVtxs == NULL) return;
|
||||
if (this->colorVtxs == NULL) { return; }
|
||||
|
||||
}
|
||||
memset(this->colorVtxs, 0xFF, 16 * sizeof(uint8_t));
|
||||
|
@ -372,8 +372,9 @@ ShaderFractalColor::ShaderFractalColor()
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, texCoords, ciTexCoordsVtxsSize);
|
||||
|
||||
|
||||
for (i = 0; i < (int32_t) ciColorVtxsSize; i++)
|
||||
for (i = 0; i < (int32_t) ciColorVtxsSize; i++) {
|
||||
colorVtxs[i] = 0xff;
|
||||
}
|
||||
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, colorVtxs, ciColorVtxsSize);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user