Compare commits
3 Commits
main
...
kikoodx/de
Author | SHA1 | Date |
---|---|---|
KikooDX | d3f4919af1 | |
KikooDX | 2a2ccb6595 | |
KikooDX | 93e06bd630 |
|
@ -7,7 +7,7 @@ project(PcAdmin C)
|
|||
include(GenerateG1A)
|
||||
include(GenerateG3A)
|
||||
include(Fxconv)
|
||||
find_package(Gint 2.4 REQUIRED)
|
||||
find_package(Gint 2.5 REQUIRED)
|
||||
|
||||
include_directories(include)
|
||||
|
||||
|
|
BIN
assets/bar3.png
BIN
assets/bar3.png
Binary file not shown.
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
|
@ -4,6 +4,7 @@ background.png:
|
|||
name: bimg_background
|
||||
bar3.png:
|
||||
type: bopti-image
|
||||
profile: p4
|
||||
name: bimg_bar3
|
||||
icons.png:
|
||||
type: bopti-image
|
||||
|
|
|
@ -25,6 +25,7 @@ struct Bar {
|
|||
enum BarID { BAR_CASH, BAR_HUMAN, BAR_SMILE, BAR_SUN };
|
||||
|
||||
struct Bar bar_init(enum BarID bar_id);
|
||||
void bar_deinit(void);
|
||||
void bar_update(struct Bar *bar);
|
||||
void bar_draw(struct Bar bar);
|
||||
/* Increase/decrease bar fill level.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "bar.h"
|
||||
#include <gint/display.h>
|
||||
|
||||
extern bopti_image_t *vimg_bar3;
|
||||
|
||||
void
|
||||
bar_draw(struct Bar bar)
|
||||
{
|
||||
|
@ -13,15 +15,15 @@ bar_draw(struct Bar bar)
|
|||
drect(bar.x, bar.y - bar.limit_height, bar.x + BAR_WIDTH - 1,
|
||||
low_y + bar.limit_height - 1, C_BLACK);
|
||||
/* draw lower limit */
|
||||
dsubimage(bar.x, low_y, &bimg_bar3, 0, bar.limit_height + 1,
|
||||
bimg_bar3.width, bar.limit_height, DIMAGE_NOCLIP);
|
||||
dsubimage(bar.x, low_y, vimg_bar3, 0, bar.limit_height + 1,
|
||||
vimg_bar3->width, bar.limit_height, DIMAGE_NOCLIP);
|
||||
/* draw higher limit */
|
||||
dsubimage(bar.x, high_y, &bimg_bar3, 0, 0, bimg_bar3.width,
|
||||
dsubimage(bar.x, high_y, vimg_bar3, 0, 0, vimg_bar3->width,
|
||||
bar.limit_height, DIMAGE_NOCLIP);
|
||||
/* draw fill */
|
||||
for (i = high_y + bar.limit_height; i < low_y; i += 1)
|
||||
dsubimage(bar.x, i, &bimg_bar3, 0, bar.limit_height,
|
||||
bimg_bar3.width, 1, DIMAGE_NOCLIP);
|
||||
dsubimage(bar.x, i, vimg_bar3, 0, bar.limit_height,
|
||||
vimg_bar3->width, 1, DIMAGE_NOCLIP);
|
||||
/* draw icons */
|
||||
dsubimage(bar.x, BAR_ICON_Y, &bimg_icons, BAR_ICON_WIDTH * bar.id, 0,
|
||||
BAR_ICON_WIDTH, BAR_ICON_HEIGHT, DIMAGE_NOCLIP);
|
||||
|
|
|
@ -1,10 +1,24 @@
|
|||
#include "bar.h"
|
||||
#include <gint/display.h>
|
||||
#include <gint/std/stdlib.h>
|
||||
#include <gint/std/string.h>
|
||||
|
||||
bopti_image_t *vimg_bar3;
|
||||
color_t *vcol_bar3; /* was black */
|
||||
|
||||
static void init_vimg_bar3(void);
|
||||
|
||||
struct Bar
|
||||
bar_init(enum BarID bar_id)
|
||||
{
|
||||
static int init_image = 1;
|
||||
int x = 0;
|
||||
|
||||
if (init_image) {
|
||||
init_image = 0;
|
||||
init_vimg_bar3();
|
||||
}
|
||||
|
||||
switch (bar_id) {
|
||||
case BAR_CASH:
|
||||
x = BAR_WIDTH;
|
||||
|
@ -31,3 +45,37 @@ bar_init(enum BarID bar_id)
|
|||
.fill = BAR_BASE_FILL,
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
bar_deinit(void)
|
||||
{
|
||||
free(vimg_bar3);
|
||||
}
|
||||
|
||||
void
|
||||
init_vimg_bar3(void)
|
||||
{
|
||||
int i;
|
||||
color_t *palette;
|
||||
|
||||
const int sizeof_bimg_bar_3 =
|
||||
sizeof(bimg_bar3) + 16 * sizeof(color_t) + /* palette */
|
||||
(bimg_bar3.width + 1) / 2 * bimg_bar3.height; /* data */
|
||||
|
||||
/* allocate memory! */
|
||||
vimg_bar3 = malloc(sizeof_bimg_bar_3);
|
||||
|
||||
/* copy original image to allocated area */
|
||||
memcpy(vimg_bar3, &bimg_bar3, sizeof_bimg_bar_3);
|
||||
|
||||
/* find black color in palette */
|
||||
palette = vimg_bar3->data;
|
||||
i = -1;
|
||||
while (++i < 16)
|
||||
if (palette[i] == C_BLACK)
|
||||
break;
|
||||
vcol_bar3 = &palette[i];
|
||||
|
||||
/* DEBUG */
|
||||
*vcol_bar3 = C_GREEN;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ main(void)
|
|||
main_draw();
|
||||
getkey();
|
||||
|
||||
/* deinit */
|
||||
bar_deinit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue