83 lines
1.8 KiB
C
83 lines
1.8 KiB
C
#include <vitasdk.h>
|
|
#include <vita2d.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <math.h>
|
|
|
|
int progress = 0;
|
|
const int totalProgress = 42; // this is like how many times updateUi is called ..
|
|
|
|
vita2d_pgf *pgf;
|
|
vita2d_pvf *pvf;
|
|
|
|
void uiInit() {
|
|
vita2d_init();
|
|
vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
|
|
pgf = vita2d_load_default_pgf();
|
|
pvf = vita2d_load_default_pvf();
|
|
}
|
|
|
|
void drawTextCenter(int y, char* text) {
|
|
int width = 0;
|
|
int height = 0;
|
|
|
|
vita2d_pgf_text_dimensions(pgf, 1.0, text, &width, &height);
|
|
|
|
int x = ((960 / 2) - (width / 2));
|
|
vita2d_pgf_draw_text(pgf, x, y, RGBA8(255,255,255,255), 1.0f, text);
|
|
}
|
|
|
|
void drawProgress() {
|
|
int end = 900;
|
|
int start = 60;
|
|
int y = 300;
|
|
int percent = (int)floor(((float)progress / (float)totalProgress) * 840.0);
|
|
char percentText[0x100];
|
|
|
|
vita2d_draw_line(start, y, end, y, RGBA8(128,128,128,255));
|
|
vita2d_draw_line(start, y, start + percent, y, RGBA8(0,255,0,255));
|
|
|
|
snprintf(percentText, sizeof(percentText), "%i%%", progress);
|
|
drawTextCenter(320, percentText);
|
|
}
|
|
|
|
void endDraw() {
|
|
vita2d_end_drawing();
|
|
vita2d_swap_buffers();
|
|
}
|
|
|
|
void startDraw() {
|
|
vita2d_start_drawing();
|
|
vita2d_clear_screen();
|
|
}
|
|
|
|
void drawLines() {
|
|
vita2d_pgf_draw_text(pgf, 20, 30, RGBA8(255,255,255,255), 1.0f, "FasterARK");
|
|
vita2d_draw_line(0, 64, 960, 64, RGBA8(255,255,255,255));
|
|
vita2d_draw_line(0, 544-64, 960, 544-64, RGBA8(255,255,255,255));
|
|
}
|
|
|
|
|
|
void displayMsg(char* title, char* msg) {
|
|
startDraw();
|
|
drawLines();
|
|
|
|
drawTextCenter(190, title);
|
|
drawTextCenter(230, msg);
|
|
|
|
endDraw();
|
|
}
|
|
|
|
void updateUi(char* msg) {
|
|
progress++;
|
|
|
|
startDraw();
|
|
drawLines();
|
|
|
|
drawTextCenter(190, "Installing ...");
|
|
drawTextCenter(230, msg);
|
|
drawProgress();
|
|
|
|
endDraw();
|
|
} |