1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * |
---|
5 | * This software was released into the Public Domain. As with most public |
---|
6 | * domain software, no warranty is made or implied by Crack dot Com or |
---|
7 | * Jonathan Clark. |
---|
8 | */ |
---|
9 | |
---|
10 | #include "config.h" |
---|
11 | |
---|
12 | #include "volumewindow.hpp" // class VolumeWindow |
---|
13 | #include "property.hpp" // class property_manager |
---|
14 | #include "gui.hpp" // ico_button |
---|
15 | |
---|
16 | VolumeWindow::VolumeWindow() : jwindow("Volume") |
---|
17 | { |
---|
18 | char const *ff = "art/frame.spe"; |
---|
19 | u_u = cash.reg(ff, "u_u", SPEC_IMAGE, 1), |
---|
20 | u_d = cash.reg(ff, "u_u", SPEC_IMAGE, 1), |
---|
21 | u_ua = cash.reg(ff, "u_ua", SPEC_IMAGE, 1), |
---|
22 | u_da = cash.reg(ff, "u_da", SPEC_IMAGE, 1), |
---|
23 | d_u = cash.reg(ff, "d_u", SPEC_IMAGE, 1), |
---|
24 | d_d = cash.reg(ff, "d_u", SPEC_IMAGE, 1), |
---|
25 | d_ua = cash.reg(ff, "d_ua", SPEC_IMAGE, 1), |
---|
26 | d_da = cash.reg(ff, "d_da", SPEC_IMAGE, 1), |
---|
27 | slider = cash.reg(ff, "volume_slide", SPEC_IMAGE, 1); |
---|
28 | x = prop->getd("volume_x", xres / 2 - 20); |
---|
29 | y = prop->getd("volume_y", yres / 2 - 50); |
---|
30 | inm->add(new ico_button(10, 27, ID_SFX_DOWN, d_u, d_d, d_ua, d_da, |
---|
31 | new ico_button(21, 27, ID_SFX_UP, u_u, u_d, u_ua, u_da, |
---|
32 | new info_field(15, 42, 0, symbol_str("SFXv"), |
---|
33 | new ico_button(10, 72, ID_MUSIC_DOWN, d_u, d_d, d_ua, d_da, |
---|
34 | new ico_button(21, 72, ID_MUSIC_UP, u_u, u_d, u_ua, u_da, |
---|
35 | new info_field(10, 86, 0, symbol_str("MUSICv"), NULL))))))); |
---|
36 | |
---|
37 | //reconfigure(); |
---|
38 | bg = cash.reg(ff, "vcontrol", SPEC_IMAGE, 1); |
---|
39 | l = cash.img(bg)->width(); |
---|
40 | h = cash.img(bg)->height(); |
---|
41 | screen = new image(l, h, NULL, 2); |
---|
42 | redraw(); |
---|
43 | } |
---|
44 | |
---|
45 | void VolumeWindow::redraw() |
---|
46 | { |
---|
47 | cash.img(bg)->put_image(screen, 0, 0); |
---|
48 | draw_music_vol(); |
---|
49 | draw_sfx_vol(); |
---|
50 | inm->redraw(); |
---|
51 | } |
---|
52 | |
---|
53 | void VolumeWindow::draw_vol(int x1, int y1, int x2, int y2, int t, |
---|
54 | int max, int c1, int c2) |
---|
55 | { |
---|
56 | int dx = x1 + t * (x2 - x1) / max; |
---|
57 | if(t != 0) |
---|
58 | { |
---|
59 | cash.img(slider)->put_image(screen, x1, y1); |
---|
60 | // screen->bar(x1,y1,dx,y2,c1); |
---|
61 | } |
---|
62 | else |
---|
63 | dx--; |
---|
64 | |
---|
65 | if(dx < x2) |
---|
66 | screen->bar(dx + 1, y1, x2, y2, c2); |
---|
67 | } |
---|
68 | |
---|
69 | void VolumeWindow::draw_sfx_vol() |
---|
70 | { |
---|
71 | draw_vol(6, 16, 34, 22, sfx_volume, 127, |
---|
72 | pal->find_closest(200, 75, 19), pal->find_closest(40, 0, 0)); |
---|
73 | } |
---|
74 | |
---|
75 | void VolumeWindow::draw_music_vol() |
---|
76 | { |
---|
77 | draw_vol(6, 61, 34, 67, music_volume, 127, |
---|
78 | pal->find_closest(255, 0, 0), pal->find_closest(40, 0, 0)); |
---|
79 | } |
---|
80 | |
---|