source: abuse/trunk/src/ui/volumewindow.cpp @ 512

Last change on this file since 512 was 512, checked in by Sam Hocevar, 11 years ago

imlib: use vec2i for image::size and unroll all necessary changes
everywhere else in the code.

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