Ignore:
Timestamp:
Aug 28, 2013, 8:11:13 PM (9 years ago)
Author:
Sam Hocevar
Message:

core: refactor some linked lists into dynamic arrays.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/branches/lol/src/gamma.cpp

    r709 r715  
    22 *  Abuse - dark 2D side-scrolling platform game
    33 *  Copyright (c) 1995 Crack dot Com
    4  *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
     4 *  Copyright (c) 2005-2013 Sam Hocevar <sam@hocevar.net>
    55 *
    66 *  This software was released into the Public Domain. As with most public
     
    1919#include "game.h"
    2020
    21 #include "jwindow.h"
     21#include "window.h"
    2222#include "lisp.h"
    2323#include "scroller.h"
     
    3030Palette *old_pal = NULL;
    3131
    32 class gray_picker : public spicker
     32class AGrayPicker : public AScrollPicker
    3333{
    3434public:
     35    AGrayPicker(ivec2 pos, int id, int start, int current)
     36      : AScrollPicker(pos, id, 1, 20, 0, 0)
     37    {
     38        cur_sel = current;
     39        sc = start;
     40        reconfigure();
     41        cur_sel = current;
     42    }
     43
    3544    int sc;
    36     virtual void draw_item(AImage *screen, int x, int y, int num, int active)
     45    virtual void DrawItem(AImage *screen, ivec2 pos, int num, int active)
    3746    {
    38         long x2 = x + item_width() - 1;
    39         long y2 = y + item_height() - 1;
    40         screen->Bar(ivec2(x, y), ivec2(x2, y2), 0);
    41         screen->Bar(ivec2(x, y), ivec2(x2 - 3, y2), sc + num);
     47        ivec2 corner = pos + ivec2(item_width() - 1, item_height() - 1);
     48        screen->Bar(pos, corner, 0);
     49        screen->Bar(pos, corner - ivec2(3, 0), sc + num);
    4250        if(active)
    4351        {
    44             screen->Rectangle(ivec2(x, y), ivec2(x2, y2), 255);
     52            screen->Rectangle(pos, corner, 255);
    4553        }
    4654    }
     
    5058    virtual int item_height() { return 20; }
    5159    virtual int activate_on_mouse_move() { return 0; }
    52 
    53     gray_picker(int X, int Y, int ID, int start, int current, ifield *Next) : spicker(X, Y, ID, 1, 20, 0, 0, Next)
    54     {
    55         cur_sel = current;
    56         sc = start;
    57         reconfigure();
    58         cur_sel=current;
    59     }
    6060};
    6161
     
    113113
    114114        int sh = wm->font()->Size().y + 35;
    115         button *but = new button(5, 5 + sh * 3, ID_GAMMA_OK, cache.img(ok_button),
    116             new info_field(35, 10 + sh * 3, ID_NULL, lang_string("gamma_msg"), 0));
    117115
    118         gray_picker *gp = new gray_picker(2, 5 + sh, ID_GREEN_PICKER, 0, dg / 4, but);
     116        AWidgetList widgets;
     117        widgets << new AButton(ivec2(5, 5 + sh * 3), ID_GAMMA_OK, cache.img(ok_button));
     118        widgets << new AInfoField(ivec2(35, 10 + sh * 3), ID_NULL, lang_string("gamma_msg"));
     119
     120        AGrayPicker *gp = new AGrayPicker(ivec2(2, 5 + sh), ID_GREEN_PICKER, 0, dg / 4);
    119121        gp->set_pos(dg / 4);
     122        widgets << gp;
    120123
    121         Jwindow *gw = wm->CreateWindow(ivec2(xres / 2 - 190,
    122                                              yres / 2 - 90), ivec2(-1), gp);
     124        AWindow *gw = wm->CreateWindow(ivec2(xres / 2 - 190,
     125                                             yres / 2 - 90), ivec2(-1), "", widgets);
    123126
    124127        Event ev;
     
    137140        } while(!abort && (ev.type != EV_MESSAGE || ev.message.id != ID_GAMMA_OK));
    138141
    139         dg = ((spicker *)gw->inm->get(ID_GREEN_PICKER))->first_selected() * 4;
     142        dg = ((AScrollPicker *)gw->inm->get(ID_GREEN_PICKER))->first_selected() * 4;
    140143
    141144        wm->close_window(gw);
Note: See TracChangeset for help on using the changeset viewer.