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