Changeset 155


Ignore:
Timestamp:
Aug 22, 2010, 6:28:22 AM (10 years ago)
Author:
sam
Message:

New MapViewer class and some GTK+ refactoring.

Location:
trunk/src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r153 r155  
    99    entity.cpp entity.h ticker.cpp ticker.h tileset.cpp tileset.h \
    1010    forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \
    11     profiler.cpp profiler.h input.h input.cpp \
     11    profiler.cpp profiler.h input.h input.cpp mapviewer.cpp mapviewer.h \
    1212    debugfps.cpp debugfps.h debugsprite.cpp debugsprite.h \
    1313    debugrecord.cpp debugrecord.h
  • trunk/src/core.h

    r153 r155  
    2727#include "game.h"
    2828#include "tileset.h"
     29#include "mapviewer.h"
    2930
    3031// Other objects
  • trunk/src/gtk/editor.cpp

    r154 r155  
    7777
    7878        /* Clear the screen, tick the renderer, show the frame and
    79          * clamp to desired framerate. */
     79         * clamp to desired framerate */
    8080        Video::Clear();
    8181        Ticker::TickDraw();
     
    101101    }
    102102
     103    /* Build the rest of the application */
    103104    GtkBuilder *builder = gtk_builder_new();
    104105    if (!gtk_builder_add_from_file(builder, "src/gtk/editor.xml", NULL))
     
    108109    }
    109110
    110     /* Create new top level window. */
    111111    GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
     112    GtkWidget *sw = GTK_WIDGET(gtk_builder_get_object(builder, "sw1"));
     113    g_object_unref(G_OBJECT(builder));
    112114
    113     /* You should always delete gtk_gl_area widgets before exit or else
    114        GLX contexts are left undeleted, this may cause problems (=core dump)
    115        in some systems.
    116        Destroy method of objects is not automatically called on exit.
    117        You need to manually enable this feature. Do gtk_quit_add_destroy()
    118        for all your top level windows unless you are certain that they get
    119        destroy signal by other means.
    120     */
    121     gtk_quit_add_destroy(1, GTK_OBJECT(window));
    122 
    123     /* Create new OpenGL widget. */
     115    /* Create new OpenGL widget */
    124116    int attrlist[] =
    125117    {
     
    133125
    134126    GtkWidget *glarea = gtk_gl_area_new(attrlist);
     127    gtk_widget_set_events(glarea, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
     128    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), glarea);
    135129
    136     gtk_widget_set_events(GTK_WIDGET(glarea),
    137                           GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
    138 
     130    /* Connect signals and show window */
    139131    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
    140132                       GTK_SIGNAL_FUNC(main_quit), NULL);
     
    146138                       GTK_SIGNAL_FUNC(init), NULL);
    147139
    148     // Create a scrolled window around our GL widget
    149     GtkWidget *sw = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow1"));
    150     gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), glarea);
     140    gtk_widget_show_all(window);
    151141
    152     /* Put scrolled window into main window */
    153     gtk_widget_show_all(GTK_WIDGET(window));
    154 
    155     // FIXME: detect when the game is killed
    156     new Game("maps/testmap.tmx");
     142    // FIXME: detect when the map viewer is killed
     143    new MapViewer("maps/testmap.tmx");
    157144    new DebugFps();
    158145
    159146    /* We tick from the idle function instead of a timeout to avoid
    160      * stealing time from the GTK loop. */
     147     * stealing time from the GTK loop when the callback time exceeds
     148     * the timeout value. */
    161149    gtk_idle_add(tick, glarea);
    162150    gtk_main();
  • trunk/src/gtk/editor.xml

    r114 r155  
    154154            <property name="can_focus">True</property>
    155155            <child>
    156               <object class="GtkScrolledWindow" id="scrolledwindow1">
     156              <object class="GtkScrolledWindow" id="sw1">
    157157                <property name="width_request">640</property>
    158158                <property name="height_request">480</property>
Note: See TracChangeset for help on using the changeset viewer.