summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--gui/Android.mk18
-rw-r--r--gui/blanktimer.cpp1
-rw-r--r--gui/button.cpp10
-rw-r--r--gui/checkbox.cpp9
-rw-r--r--gui/fileselector.cpp13
-rw-r--r--gui/input.cpp9
-rw-r--r--gui/keyboard.cpp6
-rw-r--r--gui/listbox.cpp13
-rw-r--r--gui/mousecursor.cpp4
-rw-r--r--gui/pages.cpp2
-rw-r--r--gui/partitionlist.cpp13
-rw-r--r--gui/patternpassword.cpp7
-rw-r--r--gui/progressbar.cpp9
-rw-r--r--gui/resources.cpp22
-rw-r--r--gui/resources.hpp18
-rw-r--r--gui/scrolllist.cpp17
-rw-r--r--gui/slider.cpp9
-rw-r--r--gui/slidervalue.cpp5
-rw-r--r--gui/terminal.cpp13
-rw-r--r--gui/text.cpp2
-rw-r--r--gui/textbox.cpp3
21 files changed, 124 insertions, 79 deletions
diff --git a/gui/Android.mk b/gui/Android.mk
index 909850fc4..22b534770 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -41,6 +41,7 @@ endif
LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libaosprecovery libselinux
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libziparchive
+ LOCAL_C_INCLUDES += $(LOCAL_PATH)/../otautil/include
else
LOCAL_SHARED_LIBRARIES += libminzip
LOCAL_CFLAGS += -DUSE_MINZIP
@@ -87,6 +88,7 @@ LOCAL_C_INCLUDES += \
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
LOCAL_C_INCLUDES += external/stlport/stlport
+ LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
endif
LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\"
@@ -107,7 +109,7 @@ define TW_THEME_WARNING_MSG
Could not find ui.xml for TW_THEME: $(TW_THEME)
Set TARGET_SCREEN_WIDTH and TARGET_SCREEN_HEIGHT to automatically select
an appropriate theme, or set TW_THEME to one of the following:
- $(notdir $(wildcard $(commands_recovery_local_path)/gui/theme/*_*))
+ $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
****************************************************************************
endef
define TW_CUSTOM_THEME_WARNING_MSG
@@ -117,15 +119,15 @@ define TW_CUSTOM_THEME_WARNING_MSG
Expected to find custom theme's ui.xml at:
$(TWRP_THEME_LOC)/ui.xml
Please fix this or set TW_THEME to one of the following:
- $(notdir $(wildcard $(commands_recovery_local_path)/gui/theme/*_*))
+ $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
****************************************************************************
endef
-TWRP_RES := $(commands_recovery_local_path)/gui/theme/common/fonts
-TWRP_RES += $(commands_recovery_local_path)/gui/theme/common/languages
+TWRP_RES := $(LOCAL_PATH)/theme/common/fonts
+TWRP_RES += $(LOCAL_PATH)/theme/common/languages
ifeq ($(TW_EXTRA_LANGUAGES),true)
- TWRP_RES += $(commands_recovery_local_path)/gui/theme/extra-languages/fonts
- TWRP_RES += $(commands_recovery_local_path)/gui/theme/extra-languages/languages
+ TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/fonts
+ TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/languages
endif
ifeq ($(TW_CUSTOM_THEME),)
@@ -163,13 +165,13 @@ ifeq ($(TW_CUSTOM_THEME),)
endif
endif
- TWRP_THEME_LOC := $(commands_recovery_local_path)/gui/theme/$(TW_THEME)
+ TWRP_THEME_LOC := $(LOCAL_PATH)/theme/$(TW_THEME)
ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
$(warning $(TW_THEME_WARNING_MSG))
$(error Theme selection failed; exiting)
endif
- TWRP_RES += $(commands_recovery_local_path)/gui/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
+ TWRP_RES += $(LOCAL_PATH)/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
# for future copying of used include xmls and fonts:
# UI_XML := $(TWRP_THEME_LOC)/ui.xml
# TWRP_INCLUDE_XMLS := $(shell xmllint --xpath '/recovery/include/xmlfile/@name' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp
index 220525387..63cd05c5c 100644
--- a/gui/blanktimer.cpp
+++ b/gui/blanktimer.cpp
@@ -16,7 +16,6 @@
along with TWRP. If not, see <http://www.gnu.org/licenses/>.
*/
-using namespace std;
#include <string>
#include <pthread.h>
#include <sys/time.h>
diff --git a/gui/button.cpp b/gui/button.cpp
index a9b02a305..dfae5e237 100644
--- a/gui/button.cpp
+++ b/gui/button.cpp
@@ -45,9 +45,6 @@ extern "C" {
GUIButton::GUIButton(xml_node<>* node)
: GUIObject(node)
{
- xml_attribute<>* attr;
- xml_node<>* child;
-
mButtonImg = NULL;
mButtonIcon = NULL;
mButtonLabel = NULL;
@@ -201,9 +198,12 @@ int GUIButton::SetRenderPos(int x, int y, int w, int h)
mRenderW = w;
mRenderH = h;
}
+ mIconW = mIconH = 0;
- mIconW = mButtonIcon->GetWidth();
- mIconH = mButtonIcon->GetHeight();
+ if (mButtonIcon && mButtonIcon->GetResource()) {
+ mIconW = mButtonIcon->GetWidth();
+ mIconH = mButtonIcon->GetHeight();
+ }
mTextH = 0;
mTextW = 0;
diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp
index a2958db99..de63cba36 100644
--- a/gui/checkbox.cpp
+++ b/gui/checkbox.cpp
@@ -82,10 +82,11 @@ GUICheckbox::GUICheckbox(xml_node<>* node)
DataManager::SetValue(mVarName, attr->value());
}
- mCheckW = mChecked->GetWidth();
- mCheckH = mChecked->GetHeight();
- if (mCheckW == 0)
- {
+ mCheckW = mCheckH = 0;
+ if (mChecked && mChecked->GetResource()) {
+ mCheckW = mChecked->GetWidth();
+ mCheckH = mChecked->GetHeight();
+ } else if (mUnchecked && mUnchecked->GetResource()) {
mCheckW = mUnchecked->GetWidth();
mCheckH = mUnchecked->GetHeight();
}
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index c4aaab168..fe378c848 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -112,8 +112,17 @@ GUIFileSelector::GUIFileSelector(xml_node<>* node) : GUIScrollList(node)
mFolderIcon = LoadAttrImage(child, "folder");
mFileIcon = LoadAttrImage(child, "file");
}
- int iconWidth = std::max(mFolderIcon->GetWidth(), mFileIcon->GetWidth());
- int iconHeight = std::max(mFolderIcon->GetHeight(), mFileIcon->GetHeight());
+ int iconWidth = 0, iconHeight = 0;
+ if (mFolderIcon && mFolderIcon->GetResource() && mFileIcon && mFileIcon->GetResource()) {
+ iconWidth = std::max(mFolderIcon->GetWidth(), mFileIcon->GetWidth());
+ iconHeight = std::max(mFolderIcon->GetHeight(), mFileIcon->GetHeight());
+ } else if (mFolderIcon && mFolderIcon->GetResource()) {
+ iconWidth = mFolderIcon->GetWidth();
+ iconHeight = mFolderIcon->GetHeight();
+ } else if (mFileIcon && mFileIcon->GetResource()) {
+ iconWidth = mFileIcon->GetWidth();
+ iconHeight = mFileIcon->GetHeight();
+ }
SetMaxIconSize(iconWidth, iconHeight);
// Fetch the file/folder list
diff --git a/gui/input.cpp b/gui/input.cpp
index 8dd981c24..91a1c117f 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -122,7 +122,8 @@ GUIInput::GUIInput(xml_node<>* node)
if (child)
{
mFont = LoadAttrFont(child, "resource");
- mFontHeight = mFont->GetHeight();
+ if (mFont && mFont->GetResource())
+ mFontHeight = mFont->GetHeight();
}
child = FindNode(node, "data");
@@ -299,9 +300,6 @@ int GUIInput::Render(void)
return 0;
}
- void* fontResource = NULL;
- if (mFont) fontResource = mFont->GetResource();
-
// First step, fill background
gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255);
gr_fill(mRenderX, mRenderY, mRenderW, mRenderH);
@@ -359,9 +357,6 @@ int GUIInput::GetSelection(int x, int y)
int GUIInput::NotifyTouch(TOUCH_STATE state, int x, int y)
{
static int startSelection = -1;
- void* fontResource = NULL;
-
- if (mFont) fontResource = mFont->GetResource();
if (!isConditionTrue())
return -1;
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index 849cf19d8..ca7006dc3 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -322,7 +322,7 @@ void GUIKeyboard::DrawKey(Key& key, int keyX, int keyY, int keyW, int keyH)
gr_color(mFontColorSmall.red, mFontColorSmall.green, mFontColorSmall.blue, mFontColorSmall.alpha);
}
- if (labelImage)
+ if (labelImage && labelImage->GetResource())
{
int w = labelImage->GetWidth();
int h = labelImage->GetHeight();
@@ -330,7 +330,7 @@ void GUIKeyboard::DrawKey(Key& key, int keyX, int keyY, int keyW, int keyH)
int y = keyY + (keyH - h) / 2;
gr_blit(labelImage->GetResource(), 0, 0, w, h, x, y);
}
- else if (!labelText.empty())
+ else if (!labelText.empty() && labelFont && labelFont->GetResource())
{
void* fontResource = labelFont->GetResource();
int textW = gr_ttf_measureEx(labelText.c_str(), fontResource);
@@ -342,7 +342,7 @@ void GUIKeyboard::DrawKey(Key& key, int keyX, int keyY, int keyW, int keyH)
// longpress key label (only if font is defined)
keychar = key.longpresskey;
- if (keychar > 32 && keychar < 127 && mLongpressFont->GetResource()) {
+ if (keychar > 32 && keychar < 127 && mLongpressFont && mLongpressFont->GetResource()) {
void* fontResource = mLongpressFont->GetResource();
gr_color(mLongpressFontColor.red, mLongpressFontColor.green, mLongpressFontColor.blue, mLongpressFontColor.alpha);
string text(1, keychar);
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index 05276e8ac..9d36baed7 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -44,8 +44,17 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node)
mIconSelected = LoadAttrImage(child, "selected");
mIconUnselected = LoadAttrImage(child, "unselected");
}
- int iconWidth = std::max(mIconSelected->GetWidth(), mIconUnselected->GetWidth());
- int iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight());
+ int iconWidth = 0, iconHeight = 0;
+ if (mIconSelected && mIconSelected->GetResource() && mIconUnselected && mIconUnselected->GetResource()) {
+ iconWidth = std::max(mIconSelected->GetWidth(), mIconUnselected->GetWidth());
+ iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight());
+ } else if (mIconSelected && mIconSelected->GetResource()) {
+ iconWidth = mIconSelected->GetWidth();
+ iconHeight = mIconSelected->GetHeight();
+ } else if (mIconUnselected && mIconUnselected->GetResource()) {
+ iconWidth = mIconUnselected->GetWidth();
+ iconHeight = mIconUnselected->GetHeight();
+ }
SetMaxIconSize(iconWidth, iconHeight);
// Handle the result variable
diff --git a/gui/mousecursor.cpp b/gui/mousecursor.cpp
index b87cac414..93c635ab1 100644
--- a/gui/mousecursor.cpp
+++ b/gui/mousecursor.cpp
@@ -78,7 +78,7 @@ void MouseCursor::LoadData(xml_node<>* node)
{
m_color = LoadAttrColor(child, "color", m_color);
m_image = LoadAttrImage(child, "resource");
- if (m_image)
+ if (m_image && m_image->GetResource())
{
mRenderW = m_image->GetWidth();
mRenderH = m_image->GetHeight();
@@ -99,7 +99,7 @@ int MouseCursor::Render(void)
if (!m_present)
return 0;
- if (m_image)
+ if (m_image && m_image->GetResource())
{
gr_blit(m_image->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
}
diff --git a/gui/pages.cpp b/gui/pages.cpp
index a3a1df325..fd0ad9bf3 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -42,7 +42,7 @@
#ifdef USE_MINZIP
#include "../minzip/SysUtil.h"
#else
-#include "../otautil/SysUtil.h"
+#include <otautil/SysUtil.h>
#endif
extern "C" {
diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp
index c85339152..16e09977e 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -58,8 +58,17 @@ GUIPartitionList::GUIPartitionList(xml_node<>* node) : GUIScrollList(node)
selectedList = attr->value();
}
- int iconWidth = std::max(mIconSelected->GetWidth(), mIconUnselected->GetWidth());
- int iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight());
+ int iconWidth = 0, iconHeight = 0;
+ if (mIconSelected && mIconSelected->GetResource() && mIconUnselected && mIconUnselected->GetResource()) {
+ iconWidth = std::max(mIconSelected->GetWidth(), mIconUnselected->GetWidth());
+ iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight());
+ } else if (mIconSelected && mIconSelected->GetResource()) {
+ iconWidth = mIconSelected->GetWidth();
+ iconHeight = mIconSelected->GetHeight();
+ } else if (mIconUnselected && mIconUnselected->GetResource()) {
+ iconWidth = mIconUnselected->GetWidth();
+ iconHeight = mIconUnselected->GetHeight();
+ }
SetMaxIconSize(iconWidth, iconHeight);
child = FindNode(node, "listtype");
diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp
index c31737f32..5559f9dd8 100644
--- a/gui/patternpassword.cpp
+++ b/gui/patternpassword.cpp
@@ -40,7 +40,6 @@ extern "C" {
GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
: GUIObject(node)
{
- xml_attribute<>* attr;
xml_node<>* child;
// 3x3 is the default.
@@ -107,7 +106,7 @@ GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
mDotCircle = gr_render_circle(mDotRadius, mDotColor.red, mDotColor.green, mDotColor.blue, mDotColor.alpha);
mActiveDotCircle = gr_render_circle(mDotRadius/2, mActiveDotColor.red, mActiveDotColor.green, mActiveDotColor.blue, mActiveDotColor.alpha);
}
- else
+ else if (mDotImage && mDotImage->GetResource())
mDotRadius = mDotImage->GetWidth()/2;
SetRenderPos(mRenderX, mRenderY, mRenderW, mRenderH);
@@ -210,10 +209,10 @@ int GUIPatternPassword::Render(void)
gr_blit(mActiveDotCircle, 0, 0, gr_get_width(mActiveDotCircle), gr_get_height(mActiveDotCircle), mDots[i].x + mDotRadius/2, mDots[i].y + mDotRadius/2);
}
} else {
- if (mDots[i].active) {
+ if (mDots[i].active && mActiveDotImage && mActiveDotImage->GetResource()) {
gr_blit(mActiveDotImage->GetResource(), 0, 0, mActiveDotImage->GetWidth(), mActiveDotImage->GetHeight(),
mDots[i].x + (mDotRadius - mActiveDotImage->GetWidth()/2), mDots[i].y + (mDotRadius - mActiveDotImage->GetHeight()/2));
- } else {
+ } else if (mDotImage && mDotImage->GetResource()) {
gr_blit(mDotImage->GetResource(), 0, 0, mDotImage->GetWidth(), mDotImage->GetHeight(), mDots[i].x, mDots[i].y);
}
}
diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp
index 56ce48091..defd9517b 100644
--- a/gui/progressbar.cpp
+++ b/gui/progressbar.cpp
@@ -45,7 +45,6 @@ extern "C" {
GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node)
{
- xml_attribute<>* attr;
xml_node<>* child;
mEmptyBar = NULL;
@@ -79,8 +78,12 @@ GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node)
mCurValVar = LoadAttrString(child, "name");
}
- mRenderW = mEmptyBar->GetWidth();
- mRenderH = mEmptyBar->GetHeight();
+ if (mEmptyBar && mEmptyBar->GetResource()) {
+ mRenderW = mEmptyBar->GetWidth();
+ mRenderH = mEmptyBar->GetHeight();
+ } else {
+ mRenderW = mRenderH = 0;
+ }
}
int GUIProgressBar::Render(void)
diff --git a/gui/resources.cpp b/gui/resources.cpp
index 59b8ed484..bb2fd500a 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -294,38 +294,38 @@ AnimationResource* ResourceManager::FindAnimation(const std::string& name) const
std::string ResourceManager::FindString(const std::string& name) const
{
- if (this != NULL) {
+ //if (this != NULL) {
std::map<std::string, string_resource_struct>::const_iterator it = mStrings.find(name);
if (it != mStrings.end())
return it->second.value;
LOGERR("String resource '%s' not found. No default value.\n", name.c_str());
PageManager::AddStringResource("NO DEFAULT", name, "[" + name + ("]"));
- } else {
+ /*} else {
LOGINFO("String resources not loaded when looking for '%s'. No default value.\n", name.c_str());
- }
+ }*/
return "[" + name + ("]");
}
std::string ResourceManager::FindString(const std::string& name, const std::string& default_string) const
{
- if (this != NULL) {
+ //if (this != NULL) {
std::map<std::string, string_resource_struct>::const_iterator it = mStrings.find(name);
if (it != mStrings.end())
return it->second.value;
LOGERR("String resource '%s' not found. Using default value.\n", name.c_str());
PageManager::AddStringResource("DEFAULT", name, default_string);
- } else {
+ /*} else {
LOGINFO("String resources not loaded when looking for '%s'. Using default value.\n", name.c_str());
- }
+ }*/
return default_string;
}
void ResourceManager::DumpStrings() const
{
- if (this == NULL) {
+ /*if (this == NULL) {
gui_print("No string resources\n");
return;
- }
+ }*/
std::map<std::string, string_resource_struct>::const_iterator it;
gui_print("Dumping all strings:\n");
for (it = mStrings.begin(); it != mStrings.end(); it++)
@@ -363,7 +363,7 @@ void ResourceManager::LoadResources(xml_node<>* resList, ZipWrap* pZip, std::str
if (type == "font")
{
FontResource* res = new FontResource(child, pZip);
- if (res->GetResource())
+ if (res && res->GetResource())
mFonts.push_back(res);
else {
error = true;
@@ -393,7 +393,7 @@ void ResourceManager::LoadResources(xml_node<>* resList, ZipWrap* pZip, std::str
else if (type == "image")
{
ImageResource* res = new ImageResource(child, pZip);
- if (res->GetResource())
+ if (res && res->GetResource())
mImages.push_back(res);
else {
error = true;
@@ -403,7 +403,7 @@ void ResourceManager::LoadResources(xml_node<>* resList, ZipWrap* pZip, std::str
else if (type == "animation")
{
AnimationResource* res = new AnimationResource(child, pZip);
- if (res->GetResourceCount())
+ if (res && res->GetResourceCount())
mAnimations.push_back(res);
else {
error = true;
diff --git a/gui/resources.hpp b/gui/resources.hpp
index de673184c..69bebc70e 100644
--- a/gui/resources.hpp
+++ b/gui/resources.hpp
@@ -57,8 +57,8 @@ public:
virtual ~FontResource();
public:
- void* GetResource() { return this ? mFont : NULL; }
- int GetHeight() { return gr_ttf_getMaxFontHeight(this ? mFont : NULL); }
+ void* GetResource() { return mFont; }
+ int GetHeight() { return gr_ttf_getMaxFontHeight(mFont); }
void Override(xml_node<>* node, ZipWrap* pZip);
protected:
@@ -80,9 +80,9 @@ public:
virtual ~ImageResource();
public:
- gr_surface GetResource() { return this ? mSurface : NULL; }
- int GetWidth() { return gr_get_width(this ? mSurface : NULL); }
- int GetHeight() { return gr_get_height(this ? mSurface : NULL); }
+ gr_surface GetResource() { return mSurface; }
+ int GetWidth() { return gr_get_width(mSurface); }
+ int GetHeight() { return gr_get_height(mSurface); }
protected:
gr_surface mSurface;
@@ -95,10 +95,10 @@ public:
virtual ~AnimationResource();
public:
- gr_surface GetResource() { return (!this || mSurfaces.empty()) ? NULL : mSurfaces.at(0); }
- gr_surface GetResource(int entry) { return (!this || mSurfaces.empty()) ? NULL : mSurfaces.at(entry); }
- int GetWidth() { return gr_get_width(this ? GetResource() : NULL); }
- int GetHeight() { return gr_get_height(this ? GetResource() : NULL); }
+ gr_surface GetResource() { return mSurfaces.empty() ? NULL : mSurfaces.at(0); }
+ gr_surface GetResource(int entry) { return mSurfaces.empty() ? NULL : mSurfaces.at(entry); }
+ int GetWidth() { return gr_get_width(GetResource()); }
+ int GetHeight() { return gr_get_height(GetResource()); }
int GetResourceCount() { return mSurfaces.size(); }
protected:
diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp
index 7540356bf..ecfb5fe81 100644
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -32,7 +32,6 @@ const int SCROLLING_FLOOR = 2; // minimum pixels for scrolling to stop
GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node)
{
- xml_attribute<>* attr;
xml_node<>* child;
firstDisplayedItem = mItemSpacing = mFontHeight = mSeparatorH = y_offset = scrollingSpeed = 0;
@@ -265,8 +264,10 @@ int GUIScrollList::Render(void)
}
// render the text
- gr_color(mHeaderFontColor.red, mHeaderFontColor.green, mHeaderFontColor.blue, mHeaderFontColor.alpha);
- gr_textEx_scaleW(mRenderX + IconOffsetX + 5, yPos + (int)(mHeaderH / 2), mLastHeaderValue.c_str(), mFont->GetResource(), mRenderW, TEXT_ONLY_RIGHT, 0);
+ if (mFont && mFont->GetResource()) {
+ gr_color(mHeaderFontColor.red, mHeaderFontColor.green, mHeaderFontColor.blue, mHeaderFontColor.alpha);
+ gr_textEx_scaleW(mRenderX + IconOffsetX + 5, yPos + (int)(mHeaderH / 2), mLastHeaderValue.c_str(), mFont->GetResource(), mRenderW, TEXT_ONLY_RIGHT, 0);
+ }
// Add the separator
gr_color(mHeaderSeparatorColor.red, mHeaderSeparatorColor.green, mHeaderSeparatorColor.blue, mHeaderSeparatorColor.alpha);
@@ -345,9 +346,11 @@ void GUIScrollList::RenderStdItem(int yPos, bool selected, ImageResource* icon,
}
// render label text
- int textX = mRenderX + maxIconWidth + 5;
- int textY = yPos + (iconAndTextH / 2);
- gr_textEx_scaleW(textX, textY, text, mFont->GetResource(), mRenderW, TEXT_ONLY_RIGHT, 0);
+ if (mFont && mFont->GetResource()) {
+ int textX = mRenderX + maxIconWidth + 5;
+ int textY = yPos + (iconAndTextH / 2);
+ gr_textEx_scaleW(textX, textY, text, mFont->GetResource(), mRenderW, TEXT_ONLY_RIGHT, 0);
+ }
}
int GUIScrollList::Update(void)
@@ -610,6 +613,8 @@ void GUIScrollList::SetPageFocus(int inFocus)
bool GUIScrollList::AddLines(std::vector<std::string>* origText, std::vector<std::string>* origColor, size_t* lastCount, std::vector<std::string>* rText, std::vector<std::string>* rColor)
{
+ if (!mFont || !mFont->GetResource())
+ return false;
if (*lastCount == origText->size())
return false; // nothing to add
diff --git a/gui/slider.cpp b/gui/slider.cpp
index ed5c615ce..fab5a2ea0 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -47,7 +47,6 @@ extern "C" {
GUISlider::GUISlider(xml_node<>* node) : GUIObject(node)
{
- xml_attribute<>* attr;
xml_node<>* child;
sAction = NULL;
@@ -84,8 +83,12 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node)
Placement TextPlacement = CENTER;
LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &TextPlacement);
- mRenderW = sSlider->GetWidth();
- mRenderH = sSlider->GetHeight();
+ if (sSlider && sSlider->GetResource()) {
+ mRenderW = sSlider->GetWidth();
+ mRenderH = sSlider->GetHeight();
+ } else {
+ mRenderW = mRenderH = 0;
+ }
if (TextPlacement == CENTER || TextPlacement == CENTER_X_ONLY) {
mRenderX = mRenderX - (mRenderW / 2);
if (TextPlacement == CENTER) {
diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp
index 6f007e23b..3aaffcc05 100644
--- a/gui/slidervalue.cpp
+++ b/gui/slidervalue.cpp
@@ -172,7 +172,10 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node)
mSliderH = LoadAttrIntScaleY(child, "sliderh", mSliderH);
}
- mFontHeight = mFont->GetHeight();
+ if (mFont && mFont->GetResource())
+ mFontHeight = mFont->GetHeight();
+ else
+ mFontHeight = 0;
if (mShowCurr)
{
diff --git a/gui/terminal.cpp b/gui/terminal.cpp
index 65ad2c026..b1799ce63 100644
--- a/gui/terminal.cpp
+++ b/gui/terminal.cpp
@@ -861,9 +861,12 @@ size_t GUITerminal::GetItemCount()
return engine->getLinesCount();
}
-void GUITerminal::RenderItem(size_t itemindex, int yPos, bool selected)
+void GUITerminal::RenderItem(size_t itemindex, int yPos, bool selected __unused)
{
const TerminalEngine::Line& line = engine->getLine(itemindex);
+
+ if (!mFont || !mFont->GetResource())
+ return;
gr_color(mFontColor.red, mFontColor.green, mFontColor.blue, mFontColor.alpha);
// later: handle attributes here
@@ -887,7 +890,7 @@ void GUITerminal::RenderItem(size_t itemindex, int yPos, bool selected)
}
}
-void GUITerminal::NotifySelect(size_t item_selected)
+void GUITerminal::NotifySelect(size_t item_selected __unused)
{
// do nothing - terminal ignores selections
}
@@ -897,8 +900,10 @@ void GUITerminal::InitAndResize()
// make sure the shell is started
engine->initPty();
// send window resize
- int charWidth = gr_ttf_measureEx("N", mFont->GetResource());
- engine->setSize(mRenderW / charWidth, GetDisplayItemCount(), mRenderW, mRenderH);
+ if (mFont && mFont->GetResource()) {
+ int charWidth = gr_ttf_measureEx("N", mFont->GetResource());
+ engine->setSize(mRenderW / charWidth, GetDisplayItemCount(), mRenderW, mRenderH);
+ }
}
void GUITerminal::SetPageFocus(int inFocus)
diff --git a/gui/text.cpp b/gui/text.cpp
index 61940ff9f..123b2499d 100644
--- a/gui/text.cpp
+++ b/gui/text.cpp
@@ -64,7 +64,7 @@ GUIText::GUIText(xml_node<>* node)
// Load the font, and possibly override the color
mFont = LoadAttrFont(FindNode(node, "font"), "resource");
- if (!mFont)
+ if (!mFont || !mFont->GetResource())
return;
mColor = LoadAttrColor(FindNode(node, "font"), "color", mColor);
mHighlightColor = LoadAttrColor(FindNode(node, "font"), "highlightcolor", mColor);
diff --git a/gui/textbox.cpp b/gui/textbox.cpp
index 2c7d09f99..824daf327 100644
--- a/gui/textbox.cpp
+++ b/gui/textbox.cpp
@@ -81,6 +81,9 @@ size_t GUITextBox::GetItemCount()
void GUITextBox::RenderItem(size_t itemindex, int yPos, bool selected __unused)
{
+ if (!mFont || !mFont->GetResource())
+ return;
+
// Set the color for the font
gr_color(mFontColor.red, mFontColor.green, mFontColor.blue, mFontColor.alpha);