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

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

core: rename vec2i to ivec2 and update matrix.h from Lol Engine.

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
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[555]11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
[56]14
[512]15#include "common.h"
16
[481]17#include "volumewindow.h" // class VolumeWindow
18#include "property.h"     // class property_manager
19#include "gui.h"          // ico_button
[39]20
[120]21VolumeWindow::VolumeWindow() : Jwindow("Volume")
[2]22{
[118]23    char const *ff = "art/frame.spe";
[123]24    u_u = cache.reg(ff, "u_u", SPEC_IMAGE, 1),
25    u_d = cache.reg(ff, "u_u", SPEC_IMAGE, 1),
26    u_ua = cache.reg(ff, "u_ua", SPEC_IMAGE, 1),
27    u_da = cache.reg(ff, "u_da", SPEC_IMAGE, 1),
28    d_u = cache.reg(ff, "d_u", SPEC_IMAGE, 1),
29    d_d = cache.reg(ff, "d_u", SPEC_IMAGE, 1),
30    d_ua = cache.reg(ff, "d_ua", SPEC_IMAGE, 1),
31    d_da = cache.reg(ff, "d_da", SPEC_IMAGE, 1),
32    slider = cache.reg(ff, "volume_slide", SPEC_IMAGE, 1);
[659]33    m_pos.x = prop->getd("volume_x", xres / 2 - 20);
34    m_pos.y = prop->getd("volume_y", yres / 2 - 50);
[118]35    inm->add(new ico_button(10, 27, ID_SFX_DOWN, d_u, d_d, d_ua, d_da,
36                  new ico_button(21, 27, ID_SFX_UP, u_u, u_d, u_ua, u_da,
37                      new info_field(15, 42, 0, symbol_str("SFXv"),
38                          new ico_button(10, 72, ID_MUSIC_DOWN, d_u, d_d, d_ua, d_da,
39                              new ico_button(21, 72, ID_MUSIC_UP, u_u, u_d, u_ua, u_da,
40                                  new info_field(10, 86, 0, symbol_str("MUSICv"), NULL)))))));
[124]41
[118]42    //reconfigure();
[123]43    bg = cache.reg(ff, "vcontrol", SPEC_IMAGE, 1);
[671]44    m_size = cache.img(bg)->Size();
45    m_surf = new image(m_size, NULL, 2);
[118]46    redraw();
[2]47}
48
[118]49void VolumeWindow::redraw()
[2]50{
[682]51    m_surf->PutImage(cache.img(bg), ivec2(0, 0));
[118]52    draw_music_vol();
53    draw_sfx_vol();
54    inm->redraw();
[2]55}
56
[118]57void VolumeWindow::draw_vol(int x1, int y1, int x2, int y2, int t,
58                            int max, int c1, int c2)
[2]59{
[118]60    int dx = x1 + t * (x2 - x1) / max;
61    if(t != 0)
[2]62    {
[682]63        m_surf->PutImage(cache.img(slider), ivec2(x1, y1));
[644]64//      m_surf->bar(x1,y1,dx,y2,c1);
[2]65    }
[118]66    else
67        dx--;
[2]68
[118]69    if(dx < x2)
[682]70        m_surf->Bar(ivec2(dx + 1, y1), ivec2(x2, y2), c2);
[2]71}
72
[118]73void VolumeWindow::draw_sfx_vol()
[2]74{
[118]75    draw_vol(6, 16, 34, 22, sfx_volume, 127,
76             pal->find_closest(200, 75, 19), pal->find_closest(40, 0, 0));
[2]77}
78
[118]79void VolumeWindow::draw_music_vol()
[2]80{
[118]81    draw_vol(6, 61, 34, 67, music_volume, 127,
82             pal->find_closest(255, 0, 0), pal->find_closest(40, 0, 0));
[2]83}
84
Note: See TracBrowser for help on using the repository browser.