Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Color schemes work in linux..

  • Loading branch information...
commit df6f46fd13eba087645a3b13856e6ee8ab098ebd 1 parent 64bc529
@mrkite authored
View
6 Makefile
@@ -4,7 +4,8 @@ GTK_LIB=`pkg-config --libs gtk+-2.0`
BIN=$(DESTDIR)/usr/bin
DESKTOP=$(DESTDIR)/usr/share/applications
PIXMAP=$(DESTDIR)/usr/share/pixmaps
-OBJS=minutor.o mapviewer.o
+SCHEMAS=$(DESTDIR)/usr/share/glib-2.0/schemas
+OBJS=minutor.o mapviewer.o colorschemes.o
CC=gcc
MAKE=make
CFLAGS=-Wall -std=c99 -O3
@@ -19,11 +20,12 @@ $(EXEC): $(OBJS) maplib
$(CC) -Wl,--as-needed -o $(EXEC) $(OBJS) $(LIBS) MinutorMap/MinutorMap.a
install: $(EXEC)
- install -d $(BIN) $(DESKTOP) $(PIXMAP)
+ install -d $(BIN) $(DESKTOP) $(PIXMAP) $(SCHEMAS)
install -s $(EXEC) $(BIN)
install minutor.desktop $(DESKTOP)
install minutor.png $(PIXMAP)
install minutor.xpm $(PIXMAP)
+ install com.seancode.minutor.gschema.xml $(SCHEMAS)
maplib:
cd MinutorMap && $(MAKE)
View
16 MinutorMap/blockInfo.h
@@ -129,11 +129,11 @@ static struct {
{"Jukebox", 0x8a5a40,1.0}, //54
{"Fence", 0x9f814e,1.0}, //55
{"Pumpkin", 0xc07615,1.0}, //56
-{"Brimstone", 0x95696e,1.0}, //57
-{"Barren Dirt", 0x966c78,1.0}, //58
-{"Brittle Gold", 0xf9d49c,1.0}, //59
+{"Bloodstone", 0x723a38,1.0}, //57
+{"Mud", 0x554134,1.0}, //58
+{"Brimstone", 0xf9d49c,1.0}, //59
{"Portal", 0xd67fff,1.0}, //5a
-{"Glowing Pumpkin", 0xe9b416,1.0} //5b
+{"Jack-o-Lantern", 0xe9b416,1.0} //5b
};
enum block_types {
@@ -209,11 +209,11 @@ enum block_types {
BLOCK_JUKEBOX = 0x54,
BLOCK_FENCE = 0x55,
BLOCK_PUMPKIN = 0x56,
- BLOCK_BRIMSTONE = 0x57,
- BLOCK_BARREN_DIRT = 0x58,
- BLOCK_BRITTLE_GOLD = 0x59,
+ BLOCK_BLOODSTONE = 0x57,
+ BLOCK_MUD = 0x58,
+ BLOCK_BRIMSTONE = 0x59,
BLOCK_PORTAL = 0x5a,
- BLOCK_GLOWING_PUMPKIN = 0x5b
+ BLOCK_JACK_O_LANTERN = 0x5b
};
#define numBlocks 0x5c
View
1  README
@@ -21,6 +21,7 @@ OSX -
Linux -
$ make
$ sudo make install
+ $ sudo glib-compile-schemas /usr/share/glib-2.0/schemas
Linux .deb creation -
first you need to create a pbuilder environment for Lucid (10.04 LTS).
View
415 colorschemes.c
@@ -0,0 +1,415 @@
+/*
+Copyright (c) 2010, Sean Kasun
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <gtk/gtk.h>
+#include <stdint.h>
+#include <string.h>
+#include "MinutorMap/blockInfo.h"
+
+extern void selectColorScheme(GtkMenuItem *menuItem,gpointer user_data);
+
+static void renameScheme(GtkCellRendererText *renderer,gchar *path,gchar *text,GtkTreeModel *model);
+static void editScheme(GtkButton *widget,GtkListStore *store);
+static void addScheme(GtkButton *widget,GtkListStore *store);
+static void removeScheme(GtkButton *widget,GtkListStore *store);
+static void updateColor(GtkCellRendererText *renderer,gchar *path,gchar *text,GtkTreeModel *model);
+static void updateAlpha(GtkCellRendererText *renderer,gchar *path,gchar *text,GtkTreeModel *model);
+static void renderId(GtkTreeViewColumn *column,GtkCellRenderer *cell,
+ GtkTreeModel *model,GtkTreeIter *iter,gpointer data);
+static void renderColor(GtkTreeViewColumn *column,GtkCellRenderer *cell,
+ GtkTreeModel *model,GtkTreeIter *iter,gpointer data);
+
+typedef struct
+{
+ int id;
+ char name[256];
+ uint32_t colors[256];
+} ColorScheme;
+
+GArray *schemes=NULL;
+
+static void destroy()
+{
+}
+
+GArray *menuitems=NULL;
+
+static GSettings *settings;
+static GtkMenuShell *menu;
+static int menupos;
+static GSList *itemgroup;
+void initColorSchemes(GtkMenuShell *menushell,int startpos,GSList *group)
+{
+ menu=menushell;
+ menupos=startpos;
+ itemgroup=group;
+ settings=g_settings_new("com.seancode.minutor");
+ GVariant *var=g_settings_get_value(settings,"colorschemes");
+ GVariantIter *iter;
+ g_variant_get(var,"a(sau)",&iter);
+ ColorScheme cs;
+ GVariantIter *subiter;
+ gchar *name;
+ menuitems=g_array_new(FALSE,TRUE,sizeof(GtkWidget *));
+ schemes=g_array_new(FALSE,TRUE,sizeof(ColorScheme));
+ while (g_variant_iter_loop(iter,"(sau)",&name,&subiter))
+ {
+ g_stpcpy(cs.name,name);
+ int i=0;
+ uint32_t color;
+ while (g_variant_iter_loop(subiter,"u",&color))
+ cs.colors[i++]=color;
+ cs.id=schemes->len;
+ g_array_append_val(schemes,cs);
+ GtkWidget *item=gtk_radio_menu_item_new_with_label(itemgroup,cs.name);
+ itemgroup=gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(item));
+ g_array_append_val(menuitems,item);
+ gtk_menu_shell_insert(menu,item,menupos);
+ g_signal_connect(G_OBJECT(item),"activate",
+ G_CALLBACK(selectColorScheme),GINT_TO_POINTER(cs.id));
+ }
+ g_variant_unref(var);
+}
+static void saveSchemes()
+{
+ ColorScheme *cs;
+ GVariantBuilder *builder;
+ builder=g_variant_builder_new(G_VARIANT_TYPE("a(sau)"));
+ for (int i=0;i<schemes->len;i++)
+ {
+ cs=&g_array_index(schemes,ColorScheme,i);
+ if (cs->id==-1) continue;
+ GVariantBuilder *colorbuild;
+ colorbuild=g_variant_builder_new(G_VARIANT_TYPE("au"));
+ for (int c=0;c<256;c++)
+ g_variant_builder_add(colorbuild,"u",cs->colors[c]);
+ g_variant_builder_add(builder,"(sau)",cs->name,colorbuild);
+ g_variant_builder_unref(colorbuild);
+ }
+ GVariant *value=g_variant_new("a(sau)",builder);
+ g_variant_builder_unref(builder);
+ g_settings_set_value(settings,"colorschemes",value);
+}
+
+ColorScheme *newScheme(char *name)
+{
+ ColorScheme cs;
+ g_memmove(cs.name,name,256);
+ cs.id=schemes->len;
+ g_array_append_val(schemes,cs);
+ GtkWidget *item=gtk_radio_menu_item_new_with_label(itemgroup,cs.name);
+ itemgroup=gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(item));
+ g_array_append_val(menuitems,item);
+ gtk_menu_shell_insert(menu,item,menupos);
+ g_signal_connect(G_OBJECT(item),"activate",
+ G_CALLBACK(selectColorScheme),GINT_TO_POINTER(cs.id));
+ gtk_widget_show(item);
+ return &g_array_index(schemes,ColorScheme,cs.id);
+}
+static void initScheme(ColorScheme *cs)
+{
+ for (int i=0;i<numBlocks;i++)
+ {
+ uint32_t color=blocks[i].color;
+ uint8_t r,g,b,a;
+ r=color>>16;
+ g=color>>8;
+ b=color;
+ double alpha=blocks[i].alpha;
+ r/=alpha;
+ g/=alpha;
+ b/=alpha;
+ a=alpha*255;
+ color=(r<<24)|(g<<16)|(b<<8)|a;
+ cs->colors[i]=color;
+ }
+ for (int i=numBlocks;i<256;i++)
+ cs->colors[i]=0;
+}
+
+static GtkWidget *schemeList;
+static GtkWidget *colorList;
+
+void editColorSchemes(GtkMenuItem *menuItem,gpointer user_data)
+{
+ GtkWidget *win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(win),"Color Schemes");
+ gtk_window_set_default_size(GTK_WINDOW(win),300,300);
+ g_signal_connect(G_OBJECT(win),"destroy",
+ G_CALLBACK(destroy),NULL);
+
+ //main hbox
+ GtkWidget *hbox=gtk_hbox_new(FALSE,5);
+ gtk_container_add(GTK_CONTAINER(win),hbox);
+
+ GtkListStore *store=gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT);
+
+ ColorScheme *cs;
+ GtkTreeIter iter;
+ for (int i=0;i<schemes->len;i++)
+ {
+ cs=&g_array_index(schemes,ColorScheme,i);
+ if (cs->id==-1) continue;
+ gtk_list_store_append(store,&iter);
+ gtk_list_store_set(store,&iter,
+ 0,cs->name,1,cs->id,-1);
+ }
+
+ schemeList=gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ GtkTreeSelection *sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(schemeList));
+ gtk_tree_selection_set_mode(sel,GTK_SELECTION_SINGLE);
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ renderer=gtk_cell_renderer_text_new();
+ g_object_set(renderer,"editable",TRUE,NULL);
+ g_signal_connect(G_OBJECT(renderer),"edited",
+ G_CALLBACK(renameScheme),GTK_TREE_MODEL(store));
+ column=gtk_tree_view_column_new_with_attributes(NULL,
+ renderer,"text",0,NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(schemeList),column);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(schemeList),FALSE);
+ gtk_box_pack_start(GTK_BOX(hbox),schemeList,TRUE,TRUE,0);
+
+ //button box
+ GtkWidget *vbox=gtk_vbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(hbox),vbox,FALSE,FALSE,0);
+
+ GtkWidget *edit=gtk_button_new_with_label("Edit");
+ gtk_box_pack_start(GTK_BOX(vbox),edit,FALSE,FALSE,0);
+ g_signal_connect(G_OBJECT(edit),"clicked",
+ G_CALLBACK(editScheme),store);
+
+ GtkWidget *add=gtk_button_new_with_label("Add");
+ gtk_box_pack_start(GTK_BOX(vbox),add,FALSE,FALSE,0);
+ g_signal_connect(G_OBJECT(add),"clicked",
+ G_CALLBACK(addScheme),store);
+
+ GtkWidget *remove=gtk_button_new_with_label("Remove");
+ gtk_box_pack_start(GTK_BOX(vbox),remove,FALSE,FALSE,0);
+ g_signal_connect(G_OBJECT(remove),"clicked",
+ G_CALLBACK(removeScheme),store);
+
+ gtk_widget_show_all(win);
+}
+static void renameScheme(GtkCellRendererText *renderer,gchar *path,gchar *text,GtkTreeModel *model)
+{
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter_from_string(model,&iter,path);
+ gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,text,-1);
+ int id;
+ gtk_tree_model_get(model,&iter,1,&id,-1);
+ ColorScheme *cs=&g_array_index(schemes,ColorScheme,id);
+ g_stpcpy(cs->name,text);
+ saveSchemes();
+}
+static void addScheme(GtkButton *widget,GtkListStore *store)
+{
+ ColorScheme *cs=newScheme("Color Scheme");
+ initScheme(cs);
+
+ GtkTreeIter iter;
+ gtk_list_store_append(store,&iter);
+ gtk_list_store_set(store,&iter,
+ 0,cs->name,1,cs->id,-1);
+ saveSchemes();
+}
+static void removeScheme(GtkButton *widget,GtkListStore *store)
+{
+ GtkTreeSelection *sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(schemeList));
+ GtkTreeIter iter;
+ if (gtk_tree_selection_get_selected(sel,NULL,&iter))
+ {
+ int id;
+ gtk_tree_model_get(GTK_TREE_MODEL(store),&iter,1,&id,-1);
+ gtk_list_store_remove(store,&iter);
+ ColorScheme *cs=&g_array_index(schemes,ColorScheme,id);
+ GtkWidget *w=g_array_index(menuitems,GtkWidget *,id);
+ gtk_container_remove(GTK_CONTAINER(menu),w);
+ cs->id=-1;
+ saveSchemes();
+ }
+
+}
+
+static void closeScheme()
+{
+}
+
+uint32_t *getColorScheme(int id)
+{
+ static ColorScheme standard;
+ if (id==-1)
+ {
+ initScheme(&standard);
+ return standard.colors;
+ }
+ ColorScheme *cs=&g_array_index(schemes,ColorScheme,id);
+ return cs->colors;
+}
+static ColorScheme *curScheme;
+static void editScheme(GtkButton *widget,GtkListStore *store)
+{
+ GtkTreeSelection *sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(schemeList));
+ GtkTreeIter iter;
+ if (gtk_tree_selection_get_selected(sel,NULL,&iter))
+ {
+ int id;
+ gtk_tree_model_get(GTK_TREE_MODEL(store),&iter,1,&id,-1);
+ curScheme=&g_array_index(schemes,ColorScheme,id);
+
+ GtkWidget *win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(win),"Color Scheme");
+ gtk_window_set_default_size(GTK_WINDOW(win),350,400);
+ g_signal_connect(G_OBJECT(win),"destroy",
+ G_CALLBACK(closeScheme),NULL);
+
+ //main vbox
+ GtkWidget *vbox=gtk_vbox_new(FALSE,5);
+ gtk_container_add(GTK_CONTAINER(win),vbox);
+
+ GtkListStore *substore=gtk_list_store_new(4,G_TYPE_INT,G_TYPE_STRING,G_TYPE_INT,G_TYPE_INT);
+
+ GtkTreeIter iter;
+ for (int i=0;i<numBlocks;i++)
+ {
+ gtk_list_store_append(substore,&iter);
+ gtk_list_store_set(substore,&iter,
+ 0,i,
+ 1,blocks[i].name,
+ 2,curScheme->colors[i]>>8,
+ 3,curScheme->colors[i]&0xff,
+ -1);
+ }
+
+
+ colorList=gtk_tree_view_new_with_model(GTK_TREE_MODEL(substore));
+ GtkWidget *scroll=gtk_scrolled_window_new(gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(colorList)),gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(colorList)));
+ gtk_box_pack_start(GTK_BOX(vbox),scroll,TRUE,TRUE,0);
+ gtk_container_add(GTK_CONTAINER(scroll),colorList);
+
+ GtkTreeSelection *sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(colorList));
+ gtk_tree_selection_set_mode(sel,GTK_SELECTION_SINGLE);
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ renderer=gtk_cell_renderer_text_new();
+ column=gtk_tree_view_column_new_with_attributes("Id",
+ renderer,"text",0,NULL);
+ gtk_tree_view_column_set_cell_data_func(column,renderer,
+ renderId,NULL,NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(colorList),column);
+ renderer=gtk_cell_renderer_text_new();
+ column=gtk_tree_view_column_new_with_attributes("Name",
+ renderer,"text",1,NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(colorList),column);
+ renderer=gtk_cell_renderer_text_new();
+ column=gtk_tree_view_column_new_with_attributes("Color",
+ renderer,"text",2,NULL);
+ gtk_tree_view_column_set_cell_data_func(column,renderer,
+ renderColor,NULL,NULL);
+ g_object_set(renderer,"editable",TRUE,NULL);
+ g_signal_connect(G_OBJECT(renderer),"edited",
+ G_CALLBACK(updateColor),GTK_TREE_MODEL(substore));
+ gtk_tree_view_append_column(GTK_TREE_VIEW(colorList),column);
+ renderer=gtk_cell_renderer_text_new();
+ column=gtk_tree_view_column_new_with_attributes("Alpha",
+ renderer,"text",3,NULL);
+ g_object_set(renderer,"editable",TRUE,NULL);
+ g_signal_connect(G_OBJECT(renderer),"edited",
+ G_CALLBACK(updateAlpha),GTK_TREE_MODEL(substore));
+ gtk_tree_view_append_column(GTK_TREE_VIEW(colorList),column);
+
+ gtk_widget_show_all(win);
+ }
+}
+static void updateColor(GtkCellRendererText *renderer,gchar *path,gchar *text,GtkTreeModel *model)
+{
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter_from_string(model,&iter,path);
+ int id;
+ gtk_tree_model_get(model,&iter,0,&id,-1);
+ uint32_t color=0;
+ for (int i=0;text[i];i++)
+ {
+ if (text[i]>='0' && text[i]<='9')
+ {
+ color<<=4;
+ color|=text[i]-'0';
+ }
+ if (text[i]>='a' && text[i]<='f')
+ {
+ color<<=4;
+ color|=text[i]+10-'a';
+ }
+ if (text[i]>='A' && text[i]<='F')
+ {
+ color<<=4;
+ color|=text[i]+10-'A';
+ }
+ }
+ gtk_list_store_set(GTK_LIST_STORE(model),&iter,2,color,-1);
+ curScheme->colors[id]&=0xff;
+ curScheme->colors[id]|=color<<8;
+ saveSchemes();
+}
+static void updateAlpha(GtkCellRendererText *renderer,gchar *path,gchar *text,GtkTreeModel *model)
+{
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter_from_string(model,&iter,path);
+ int id;
+ gtk_tree_model_get(model,&iter,0,&id,-1);
+ uint8_t alpha=0;
+ for (int i=0;text[i];i++)
+ {
+ if (text[i]>='0' && text[i]<='9')
+ {
+ alpha*=10;
+ alpha+=text[i]-'0';
+ }
+ }
+ gtk_list_store_set(GTK_LIST_STORE(model),&iter,3,alpha,-1);
+ curScheme->colors[id]&=~0xff;
+ curScheme->colors[id]|=alpha;
+ saveSchemes();
+}
+static void renderId(GtkTreeViewColumn *column,GtkCellRenderer *cell,
+ GtkTreeModel *model,GtkTreeIter *iter,gpointer data)
+{
+ int id;
+ gtk_tree_model_get(model,iter,0,&id,-1);
+ gchar *name=g_strdup_printf("%d.",id);
+ g_object_set(G_OBJECT(cell),"text",name,NULL);
+ g_free(name);
+}
+static void renderColor(GtkTreeViewColumn *column,GtkCellRenderer *cell,
+ GtkTreeModel *model,GtkTreeIter *iter,gpointer data)
+{
+ uint32_t color;
+ gtk_tree_model_get(model,iter,2,&color,-1);
+ gchar *name=g_strdup_printf("#%06x",color);
+ g_object_set(G_OBJECT(cell),"text",name,NULL);
+ g_free(name);
+}
View
37 colorschemes.h
@@ -0,0 +1,37 @@
+/*
+Copyright (c) 2010, Sean Kasun
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __COLORSCHEMES_H__
+#define __COLORSCHEMES_H__
+
+#include <stdint.h>
+
+void initColorSchemes(GtkMenuShell *menushell,int startpos,GSList *group);
+void editColorSchemes(GtkMenuItem *menuItem,gpointer user_data);
+uint32_t *getColorScheme(int id);
+
+#endif
View
7 com.seancode.minutor.gschema.xml
@@ -0,0 +1,7 @@
+<schemalist>
+ <schema id="com.seancode.minutor" path="/apps/minutor/">
+ <key name="colorschemes" type="a(sau)">
+ <default>[]</default>
+ </key>
+ </schema>
+</schemalist>
View
12 debian/changelog
@@ -1,3 +1,15 @@
+minutor (0.9) unstable; urgency=low
+
+ * Color scheme editor
+ * Hell mode
+ * New blocks from hell
+ * Lighting
+ * Cave modes
+ * Depth shading
+ * Obscured toggle
+
+ -- Sean Kasun <sean@seancode.com> Sun, 31 Oct 2010 02:18:33 -0700
+
minutor (0.3.1) unstable; urgency=low
* Floating point fix
View
63 mapviewer.c
@@ -29,6 +29,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <gdk/gdkkeysyms.h>
#include "MinutorMap/MinutorMap.h"
#include "minutor.xpm"
+#include "colorschemes.h"
#define MINZOOM 1.0
#define MAXZOOM 10.0
@@ -36,7 +37,8 @@ THE POSSIBILITY OF SUCH DAMAGE.
static GtkWidget *win;
static GtkWidget *slider,*da,*status;
static GtkWidget *jumpplayer,*jumpspawn;
-static GtkWidget *lighting, *cavemode, *hideobscured, *depthshading;
+static GtkWidget *lighting, *cavemode, *hideobscured, *depthshading, *hell;
+static GtkWidget *standard;
static double curX,curZ;
static int curDepth=127;
static double curScale=1.0;
@@ -73,6 +75,7 @@ static gboolean drawMap(GtkWidget *widget)
opts|=gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(hideobscured))?HIDEOBSCURED:0;
opts|=gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(depthshading))?DEPTHSHADING:0;
opts|=gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lighting))?LIGHTING:0;
+ opts|=gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(hell))?HELL:0;
DrawMap(world,curX,curZ,curDepth,curWidth,curHeight,curScale,bits,opts);
@@ -304,6 +307,28 @@ static void jumpToPlayer(GtkMenuItem *menuItem,gpointer user_data)
curZ=playerZ;
gdk_window_invalidate_rect(da->window,NULL,FALSE);
}
+static void toggleHell(GtkMenuItem *menuItem,gpointer user_data)
+{
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(hell)))
+ {
+ curX/=16.0;
+ curZ/=16.0;
+ }
+ else
+ {
+ curX*=16.0;
+ curZ*=16.0;
+ }
+ CloseAll();
+ gdk_window_invalidate_rect(da->window,NULL,FALSE);
+}
+void selectColorScheme(GtkMenuItem *menuItem,gpointer user_data)
+{
+ int id=GPOINTER_TO_INT(user_data);
+ uint32_t *colors=getColorScheme(id);
+ SetMapPalette(colors,256);
+ gdk_window_invalidate_rect(da->window,NULL,FALSE);
+}
void createMapViewer()
{
@@ -383,6 +408,38 @@ void createMapViewer()
g_signal_connect(G_OBJECT(jumpplayer),"activate",
G_CALLBACK(jumpToPlayer),NULL);
gtk_widget_set_sensitive(jumpplayer,FALSE);
+
+ GtkWidget *sep2=gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(viewitems),sep2);
+
+ hell=gtk_check_menu_item_new_with_label("Hell");
+ gtk_widget_add_accelerator(hell,"activate",menuGroup,
+ GDK_F5,0,GTK_ACCEL_VISIBLE);
+ gtk_menu_shell_append(GTK_MENU_SHELL(viewitems),hell);
+ g_signal_connect(G_OBJECT(hell),"activate",
+ G_CALLBACK(toggleHell),NULL);
+
+ GtkWidget *sep3=gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(viewitems),sep3);
+
+
+ GtkWidget *colormenu=gtk_menu_item_new_with_mnemonic("_Colors");
+ gtk_menu_shell_append(GTK_MENU_SHELL(menubar),colormenu);
+ GtkWidget *coloritems=gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(colormenu),coloritems);
+
+ standard=gtk_radio_menu_item_new_with_label(NULL,"Standard");
+ GSList *group=gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(standard));
+ gtk_menu_shell_append(GTK_MENU_SHELL(coloritems),standard);
+ g_signal_connect(G_OBJECT(standard),"activate",
+ G_CALLBACK(selectColorScheme),GINT_TO_POINTER(-1));
+ GtkWidget *sep4=gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(coloritems),sep4);
+
+ GtkWidget *colorschemes=gtk_menu_item_new_with_label("Color Schemes...");
+ gtk_menu_shell_append(GTK_MENU_SHELL(coloritems),colorschemes);
+ g_signal_connect(G_OBJECT(colorschemes),"activate",
+ G_CALLBACK(editColorSchemes),NULL);
gtk_window_add_accel_group(GTK_WINDOW(win),menuGroup);
@@ -432,6 +489,7 @@ void createMapViewer()
gtk_menu_shell_append(GTK_MENU_SHELL(viewitems),lighting);
g_signal_connect(G_OBJECT(lighting),"toggled",
G_CALLBACK(drawMap),NULL);
+
cavemode=gtk_check_menu_item_new_with_mnemonic("_Cave Mode");
gtk_widget_add_accelerator(cavemode,"activate",menuGroup,
@@ -461,6 +519,9 @@ void createMapViewer()
bits=g_malloc(curWidth*curHeight*4);
+ // 2 = position to start inserting color schemes
+ initColorSchemes(GTK_MENU_SHELL(coloritems),1,group);
+
//and show it
gtk_widget_show_all(win);
}

0 comments on commit df6f46f

Please sign in to comment.
Something went wrong with that request. Please try again.