1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-31 20:41:45 +01:00

RSX/Overlays: formatted comments

This commit is contained in:
Megamouse 2018-10-02 20:27:13 +02:00
parent 348db050ae
commit 9693d1c3a3
4 changed files with 67 additions and 67 deletions

View File

@ -26,12 +26,12 @@ namespace rsx
{ {
enum image_resource_id : u8 enum image_resource_id : u8
{ {
//NOTE: 1 - 252 are user defined // NOTE: 1 - 252 are user defined
none = 0, //No image none = 0, // No image
raw_image = 252, //Raw image data passed via image_info struct raw_image = 252, // Raw image data passed via image_info struct
font_file = 253, //Font file font_file = 253, // Font file
game_icon = 254, //Use game icon game_icon = 254, // Use game icon
backbuffer = 255 //Use current backbuffer contents backbuffer = 255 // Use current backbuffer contents
}; };
struct vertex struct vertex
@ -111,10 +111,10 @@ namespace rsx
const u32 width = 1024; const u32 width = 1024;
const u32 height = 1024; const u32 height = 1024;
const u32 oversample = 2; const u32 oversample = 2;
const u32 char_count = 256; //16x16 grid at max 48pt const u32 char_count = 256; // 16x16 grid at max 48pt
f32 size_pt = 12.f; f32 size_pt = 12.f;
f32 size_px = 16.f; //Default font 12pt size f32 size_px = 16.f; // Default font 12pt size
f32 em_size = 0.f; f32 em_size = 0.f;
std::string font_name; std::string font_name;
std::vector<stbtt_packedchar> pack_info; std::vector<stbtt_packedchar> pack_info;
@ -123,7 +123,7 @@ namespace rsx
font(const char *ttf_name, f32 size) font(const char *ttf_name, f32 size)
{ {
//Init glyph // Init glyph
std::vector<u8> bytes; std::vector<u8> bytes;
std::vector<std::string> font_dirs; std::vector<std::string> font_dirs;
std::vector<std::string> fallback_fonts; std::vector<std::string> fallback_fonts;
@ -144,21 +144,21 @@ namespace rsx
fallback_fonts.push_back("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"); //ubuntu fallback_fonts.push_back("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"); //ubuntu
fallback_fonts.push_back("/usr/share/fonts/TTF/DejaVuSans.ttf"); //arch fallback_fonts.push_back("/usr/share/fonts/TTF/DejaVuSans.ttf"); //arch
#endif #endif
//Search dev_flash for the font too // Search dev_flash for the font too
font_dirs.push_back(g_cfg.vfs.get_dev_flash() + "data/font/"); font_dirs.push_back(g_cfg.vfs.get_dev_flash() + "data/font/");
font_dirs.push_back(g_cfg.vfs.get_dev_flash() + "data/font/SONY-CC/"); font_dirs.push_back(g_cfg.vfs.get_dev_flash() + "data/font/SONY-CC/");
//Attempt to load a font from dev_flash as a last resort // Attempt to load a font from dev_flash as a last resort
fallback_fonts.push_back(g_cfg.vfs.get_dev_flash() + "data/font/SCE-PS3-VR-R-LATIN.TTF"); fallback_fonts.push_back(g_cfg.vfs.get_dev_flash() + "data/font/SCE-PS3-VR-R-LATIN.TTF");
//Attemt to load requested font // Attemt to load requested font
std::string file_path; std::string file_path;
bool font_found = false; bool font_found = false;
for (auto& font_dir : font_dirs) for (auto& font_dir : font_dirs)
{ {
std::string requested_file = font_dir + ttf_name; std::string requested_file = font_dir + ttf_name;
//Append ".ttf" if not present // Append ".ttf" if not present
std::string font_lower(requested_file); std::string font_lower(requested_file);
std::transform(requested_file.begin(), requested_file.end(), font_lower.begin(), ::tolower); std::transform(requested_file.begin(), requested_file.end(), font_lower.begin(), ::tolower);
@ -174,7 +174,7 @@ namespace rsx
} }
} }
//Attemt to load a fallback if request font wasn't found // Attemt to load a fallback if request font wasn't found
if (!font_found) if (!font_found)
{ {
for (auto &fallback_font : fallback_fonts) for (auto &fallback_font : fallback_fonts)
@ -190,7 +190,7 @@ namespace rsx
} }
} }
//Read font // Read font
if (font_found) if (font_found)
{ {
fs::file f(file_path); fs::file f(file_path);
@ -214,7 +214,7 @@ namespace rsx
stbtt_PackSetOversampling(&context, oversample, oversample); stbtt_PackSetOversampling(&context, oversample, oversample);
//Convert pt to px // Convert pt to px
size_px = ceilf((f32)size * 96.f / 72.f); size_px = ceilf((f32)size * 96.f / 72.f);
size_pt = size; size_pt = size;
@ -263,7 +263,7 @@ namespace rsx
{ {
if ((u32)c >= char_count) if ((u32)c >= char_count)
{ {
//Unsupported glyph, render null for now // Unsupported glyph, render null for now
c = ' '; c = ' ';
} }
@ -300,7 +300,7 @@ namespace rsx
if (wrap) if (wrap)
{ {
//scan previous chars // scan previous chars
for (int j = i - 1, nb_chars = 0; j > 0; j--, nb_chars++) for (int j = i - 1, nb_chars = 0; j > 0; j--, nb_chars++)
{ {
if (text[j] == '\n') if (text[j] == '\n')
@ -326,7 +326,7 @@ namespace rsx
auto char_index = n / 4; auto char_index = n / 4;
if (text[char_index] == ' ') if (text[char_index] == ' ')
{ {
//Skip character // Skip character
result[n++].vec2(0.f, 0.f); result[n++].vec2(0.f, 0.f);
result[n++].vec2(0.f, 0.f); result[n++].vec2(0.f, 0.f);
result[n++].vec2(0.f, 0.f); result[n++].vec2(0.f, 0.f);
@ -365,7 +365,7 @@ namespace rsx
if (!wrapped) if (!wrapped)
{ {
//TODO: Ellipsize // TODO: Ellipsize
break; break;
} }
} }
@ -376,7 +376,7 @@ namespace rsx
result.push_back({ quad.x1, quad.y1, quad.s1, quad.t1 }); result.push_back({ quad.x1, quad.y1, quad.s1, quad.t1 });
break; break;
} }
} //switch } // switch
} }
else else
{ {
@ -389,7 +389,7 @@ namespace rsx
}; };
//TODO: Singletons are cancer // TODO: Singletons are cancer
class fontmgr class fontmgr
{ {
private: private:
@ -479,7 +479,7 @@ namespace rsx
new_entry new_entry
}; };
//Define resources // Define resources
std::vector<std::string> texture_resource_files; std::vector<std::string> texture_resource_files;
std::vector<std::unique_ptr<image_info>> texture_raw_data; std::vector<std::unique_ptr<image_info>> texture_raw_data;
@ -499,12 +499,12 @@ namespace rsx
{ {
for (const auto &res : texture_resource_files) for (const auto &res : texture_resource_files)
{ {
//First check the global config dir // First check the global config dir
auto info = std::make_unique<image_info>((fs::get_config_dir() + "Icons/ui/" + res).c_str()); auto info = std::make_unique<image_info>((fs::get_config_dir() + "Icons/ui/" + res).c_str());
if (info->data == nullptr) if (info->data == nullptr)
{ {
//Resource was not found in config dir, try and grab from relative path (linux) // Resource was not found in config dir, try and grab from relative path (linux)
info = std::make_unique<image_info>(("Icons/ui/" + res).c_str()); info = std::make_unique<image_info>(("Icons/ui/" + res).c_str());
#ifndef _WIN32 #ifndef _WIN32
// Check for Icons in ../share/rpcs3 for AppImages and /usr/bin/ // Check for Icons in ../share/rpcs3 for AppImages and /usr/bin/
@ -528,7 +528,7 @@ namespace rsx
#endif #endif
if (info->data != nullptr) if (info->data != nullptr)
{ {
//Install the image to config dir // Install the image to config dir
auto dst_dir = fs::get_config_dir() + "Icons/ui/"; auto dst_dir = fs::get_config_dir() + "Icons/ui/";
auto src = "Icons/ui/" + res; auto src = "Icons/ui/" + res;
auto dst = dst_dir + res; auto dst = dst_dir + res;
@ -696,7 +696,7 @@ namespace rsx
virtual void refresh() virtual void refresh()
{ {
//Just invalidate for draw when get_compiled() is called // Just invalidate for draw when get_compiled() is called
is_compiled = false; is_compiled = false;
} }
@ -813,20 +813,20 @@ namespace rsx
{ {
for (auto &v : result) for (auto &v : result)
{ {
//Check for real text region extent // Check for real text region extent
//TODO: Ellipsis // TODO: Ellipsis
text_extents_w = std::max(v.values[0], text_extents_w); text_extents_w = std::max(v.values[0], text_extents_w);
//Apply transform. // Apply transform.
//(0, 0) has text sitting one line off the top left corner (text is outside the rect) hence the offset by text height // (0, 0) has text sitting one line off the top left corner (text is outside the rect) hence the offset by text height
v.values[0] += x + padding_left; v.values[0] += x + padding_left;
v.values[1] += y + padding_top + (f32)renderer->size_px; v.values[1] += y + padding_top + (f32)renderer->size_px;
} }
if (alignment == center) if (alignment == center)
{ {
//Scan for lines and measure them // Scan for lines and measure them
//Reposition them to the center // Reposition them to the center
std::vector<std::pair<u32, u32>> lines; std::vector<std::pair<u32, u32>> lines;
u32 line_begin = 0; u32 line_begin = 0;
u32 ctr = 0; u32 ctr = 0;
@ -952,7 +952,7 @@ namespace rsx
if ((u32)c > renderer->char_count) if ((u32)c > renderer->char_count)
{ {
//Non-existent glyph // Non-existent glyph
text_width += renderer->em_size; text_width += renderer->em_size;
} }
else else
@ -999,7 +999,7 @@ namespace rsx
layout_container() layout_container()
{ {
//Transparent by default // Transparent by default
back_color.a = 0.f; back_color.a = 0.f;
} }
@ -1082,18 +1082,18 @@ namespace rsx
if (item_y_limit < 0 || item_y_base > h) if (item_y_limit < 0 || item_y_base > h)
{ {
//Out of bounds // Out of bounds
continue; continue;
} }
else if (item_y_limit > h || item_y_base < 0) else if (item_y_limit > h || item_y_base < 0)
{ {
//Partial render // Partial render
areaf clip_rect = { (f32)x, (f32)y, (f32)(x + w), (f32)(y + h) }; areaf clip_rect = { (f32)x, (f32)y, (f32)(x + w), (f32)(y + h) };
result.add(item->get_compiled(), 0.f, global_y_offset, clip_rect); result.add(item->get_compiled(), 0.f, global_y_offset, clip_rect);
} }
else else
{ {
//Normal // Normal
result.add(item->get_compiled(), 0.f, global_y_offset); result.add(item->get_compiled(), 0.f, global_y_offset);
} }
} }
@ -1156,18 +1156,18 @@ namespace rsx
if (item_x_limit < 0 || item_x_base > h) if (item_x_limit < 0 || item_x_base > h)
{ {
//Out of bounds // Out of bounds
continue; continue;
} }
else if (item_x_limit > h || item_x_base < 0) else if (item_x_limit > h || item_x_base < 0)
{ {
//Partial render // Partial render
areaf clip_rect = { (f32)x, (f32)y, (f32)(x + w), (f32)(y + h) }; areaf clip_rect = { (f32)x, (f32)y, (f32)(x + w), (f32)(y + h) };
result.add(item->get_compiled(), global_x_offset, 0.f, clip_rect); result.add(item->get_compiled(), global_x_offset, 0.f, clip_rect);
} }
else else
{ {
//Normal // Normal
result.add(item->get_compiled(), global_x_offset, 0.f); result.add(item->get_compiled(), global_x_offset, 0.f);
} }
} }
@ -1184,13 +1184,13 @@ namespace rsx
} }
}; };
//Controls // Controls
struct spacer : public overlay_element struct spacer : public overlay_element
{ {
using overlay_element::overlay_element; using overlay_element::overlay_element;
compiled_resource& get_compiled() override compiled_resource& get_compiled() override
{ {
//No draw // No draw
return compiled_resources; return compiled_resources;
} }
}; };
@ -1259,8 +1259,8 @@ namespace rsx
image_button() image_button()
{ {
//Do not clip text to region extents // Do not clip text to region extents
//TODO: Define custom clipping region or use two controls to emulate // TODO: Define custom clipping region or use two controls to emulate
clip_text = false; clip_text = false;
} }
@ -1273,7 +1273,7 @@ namespace rsx
void set_size(u16 /*w*/, u16 h) override void set_size(u16 /*w*/, u16 h) override
{ {
image_view::set_size(h, h); image_view::set_size(h, h);
m_text_offset = (h / 2) + text_horizontal_offset; //By default text is at the horizontal center m_text_offset = (h / 2) + text_horizontal_offset; // By default text is at the horizontal center
} }
compiled_resource& get_compiled() override compiled_resource& get_compiled() override
@ -1285,7 +1285,7 @@ namespace rsx
{ {
if (cmd.config.texture_ref == image_resource_id::font_file) if (cmd.config.texture_ref == image_resource_id::font_file)
{ {
//Text, translate geometry to the right // Text, translate geometry to the right
for (auto &v : cmd.verts) for (auto &v : cmd.verts)
{ {
v.values[0] += m_text_offset; v.values[0] += m_text_offset;
@ -1499,7 +1499,7 @@ namespace rsx
{ {
auto current_element = m_items[m_selected_entry * 2].get(); auto current_element = m_items[m_selected_entry * 2].get();
//Calculate bounds // Calculate bounds
auto min_y = current_element->y - y; auto min_y = current_element->y - y;
auto max_y = current_element->y + current_element->h + pack_padding + 2 - y; auto max_y = current_element->y + current_element->h + pack_padding + 2 - y;
@ -1552,11 +1552,11 @@ namespace rsx
void add_entry(std::unique_ptr<overlay_element>& entry) void add_entry(std::unique_ptr<overlay_element>& entry)
{ {
//Add entry view // Add entry view
add_element(entry); add_element(entry);
m_elements_count++; m_elements_count++;
//Add separator // Add separator
auto separator = std::make_unique<overlay_element>(); auto separator = std::make_unique<overlay_element>();
separator->back_color = fore_color; separator->back_color = fore_color;
separator->w = w; separator->w = w;

View File

@ -6,12 +6,12 @@ namespace rsx
{ {
namespace overlays namespace overlays
{ {
//Singleton instance declaration // Singleton instance declaration
fontmgr* fontmgr::m_instance = nullptr; fontmgr* fontmgr::m_instance = nullptr;
void user_interface::close() void user_interface::close()
{ {
//Force unload // Force unload
exit = true; exit = true;
if (auto manager = fxm::get<display_manager>()) if (auto manager = fxm::get<display_manager>())
{ {

View File

@ -172,7 +172,7 @@ namespace rsx
refresh(); refresh();
} }
//Unreachable // Unreachable
return 0; return 0;
} }
}; };
@ -497,7 +497,7 @@ namespace rsx
} }
else else
{ {
//Fallback // Fallback
static_cast<image_view*>(image.get())->set_image_resource(resource_config::standard_image_resource::save); static_cast<image_view*>(image.get())->set_image_resource(resource_config::standard_image_resource::save);
} }
@ -516,10 +516,10 @@ namespace rsx
subtext->set_font("Arial", 14); subtext->set_font("Arial", 14);
subtext->set_wrap_text(true); subtext->set_wrap_text(true);
//Auto-resize save details label // Auto-resize save details label
static_cast<label*>(subtext.get())->auto_resize(true); static_cast<label*>(subtext.get())->auto_resize(true);
//Make back color transparent for text // Make back color transparent for text
header_text->back_color.a = 0.f; header_text->back_color.a = 0.f;
subtext->back_color.a = 0.f; subtext->back_color.a = 0.f;
@ -528,7 +528,7 @@ namespace rsx
static_cast<vertical_layout*>(text_stack.get())->add_element(header_text); static_cast<vertical_layout*>(text_stack.get())->add_element(header_text);
static_cast<vertical_layout*>(text_stack.get())->add_element(subtext); static_cast<vertical_layout*>(text_stack.get())->add_element(subtext);
//Pack // Pack
this->pack_padding = 15; this->pack_padding = 15;
add_element(image); add_element(image);
add_element(text_stack); add_element(text_stack);
@ -581,7 +581,7 @@ namespace rsx
if (m_no_saves) if (m_no_saves)
break; break;
return_code = m_list->get_selected_index(); return_code = m_list->get_selected_index();
//Fall through // Fall through
case pad_button::circle: case pad_button::circle:
close(); close();
break; break;
@ -852,7 +852,7 @@ namespace rsx
} }
else if (cancel_only) else if (cancel_only)
{ {
//Do not accept for cancel-only dialogs // Do not accept for cancel-only dialogs
return; return;
} }
else else
@ -866,7 +866,7 @@ namespace rsx
{ {
if (ok_only) if (ok_only)
{ {
//Ignore cancel operation for Ok-only // Ignore cancel operation for Ok-only
return; return;
} }
else if (cancel_only) else if (cancel_only)
@ -901,7 +901,7 @@ namespace rsx
offset = 98; offset = 98;
} }
//Push the other stuff down // Push the other stuff down
bottom_bar.translate(0, offset); bottom_bar.translate(0, offset);
btn_ok.translate(0, offset); btn_ok.translate(0, offset);
btn_cancel.translate(0, offset); btn_cancel.translate(0, offset);
@ -1143,7 +1143,7 @@ namespace rsx
void update_animation(u64 t) void update_animation(u64 t)
{ {
//Update rate is twice per second // Update rate is twice per second
auto elapsed = t - creation_time; auto elapsed = t - creation_time;
elapsed /= 500000; elapsed /= 500000;
@ -1163,7 +1163,7 @@ namespace rsx
} }
} }
//Extends visible time by half a second. Also updates the screen // Extends visible time by half a second. Also updates the screen
void touch() void touch()
{ {
if (urgency_ctr == 0 || urgency_ctr > 8) if (urgency_ctr == 0 || urgency_ctr > 8)
@ -1184,7 +1184,7 @@ namespace rsx
update_animation(current_time); update_animation(current_time);
//Usually this method is called during a draw-to-screen operation. Reset urgency ctr // Usually this method is called during a draw-to-screen operation. Reset urgency ctr
urgency_ctr = 1; urgency_ctr = 1;
} }

View File

@ -16,7 +16,7 @@ struct PadInfo
class pad_thread class pad_thread
{ {
public: public:
pad_thread(void *_curthread, void *_curwindow); //void * instead of QThread * and QWindow * because of include in emucore pad_thread(void *_curthread, void *_curwindow); // void * instead of QThread * and QWindow * because of include in emucore
~pad_thread(); ~pad_thread();
void Init(const u32 max_connect); void Init(const u32 max_connect);
@ -27,10 +27,10 @@ public:
protected: protected:
void ThreadFunc(); void ThreadFunc();
//List of all handlers // List of all handlers
std::map<pad_handler, std::shared_ptr<PadHandlerBase>> handlers; std::map<pad_handler, std::shared_ptr<PadHandlerBase>> handlers;
//Used for pad_handler::keyboard // Used for pad_handler::keyboard
void *curthread; void *curthread;
void *curwindow; void *curwindow;