Exemplo n.º 1
0
void
initialize_app_menubar (GApplication *application)
{
	GtkBuilder *builder;
	GSettings  *settings;

	g_action_map_add_action_entries (G_ACTION_MAP (application),
					 app_menu_entries,
					 G_N_ELEMENTS (app_menu_entries),
					 application);

	builder = _gtk_builder_new_from_resource ("app-menubar.ui");
	gtk_application_set_menubar (GTK_APPLICATION (application),
				     G_MENU_MODEL (gtk_builder_get_object (builder, "app-menubar")));
	g_object_unref (builder);

	settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI);
	g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR),
				   g_variant_new_boolean (g_settings_get_boolean (settings, PREF_UI_VIEW_SIDEBAR)));

	settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING);
	g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE),
				   g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE,
						   	 g_settings_get_enum (settings, PREF_LISTING_LIST_MODE))->value_nick));

	g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI),
			  "changed::" PREF_UI_VIEW_SIDEBAR,
			  G_CALLBACK (pref_view_sidebar_changed),
			  application);
	g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING),
			  "changed::" PREF_LISTING_LIST_MODE,
			  G_CALLBACK (pref_list_mode_changed),
			  application);
}
Exemplo n.º 2
0
void
initialize_app_menu (GApplication *application)
{
	GSettings *settings;

	g_action_map_add_action_entries (G_ACTION_MAP (application),
					 app_menu_entries,
					 G_N_ELEMENTS (app_menu_entries),
					 application);
	_gtk_application_add_accelerators (GTK_APPLICATION (application), fr_app_accelerators, G_N_ELEMENTS (fr_app_accelerators));

	settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI);
	g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR),
				   g_variant_new_boolean (g_settings_get_boolean (settings, PREF_UI_VIEW_SIDEBAR)));

	settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING);
	g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE),
				   g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE,
						   	 g_settings_get_enum (settings, PREF_LISTING_LIST_MODE))->value_nick));

	g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI),
			  "changed::" PREF_UI_VIEW_SIDEBAR,
			  G_CALLBACK (pref_view_sidebar_changed),
			  application);
	g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING),
			  "changed::" PREF_LISTING_LIST_MODE,
			  G_CALLBACK (pref_list_mode_changed),
			  application);
}
Exemplo n.º 3
0
static void
update_app_menu_sensitivity (GApplication *application)
{
	GVariant         *state;
	FrWindowListMode  list_mode;

	state = g_action_get_state (G_ACTION (GET_ACTION (PREF_LISTING_LIST_MODE)));
	list_mode = _g_enum_type_get_value_by_nick (FR_TYPE_WINDOW_LIST_MODE, g_variant_get_string (state, NULL))->value;
	g_variant_unref (state);

	g_simple_action_set_enabled (GET_ACTION (PREF_UI_VIEW_SIDEBAR), list_mode == FR_WINDOW_LIST_MODE_AS_DIR);
}
Exemplo n.º 4
0
static uint64_t get_next_comb(uint64_t comb)
{
    int i = 0, need_inc = 1;
    uint64_t ret = 0;

    for (;;) {
        int action = GET_ACTION(comb, i);
        if (i == NB_ACTIONS)
            return EOA;
        if (!action && !need_inc)
            break;
        if (need_inc) {
            action++;
            if (action == NB_ACTIONS)
                action = 1; // back to first action
            else
                need_inc = 0;
        }
        ret |= action << (i*BITS_PER_ACTION);
        i++;
    }
    if (has_dup(ret))
        return get_next_comb(ret);
    return ret;
}
Exemplo n.º 5
0
static int exec_comb(const char *filename, uint64_t comb, int opt_test_flags)
{
    int i, ret = 0;
    struct sxplayer_ctx *s = sxplayer_create(filename);
    if (!s)
        return -1;

    sxplayer_set_option(s, "auto_hwaccel", 0);

    print_comb_name(comb, opt_test_flags);

    if (opt_test_flags & FLAG_SKIP)          sxplayer_set_option(s, "skip",          TESTVAL_SKIP);
    if (opt_test_flags & FLAG_TRIM_DURATION) sxplayer_set_option(s, "trim_duration", TESTVAL_TRIM_DURATION);
    if (opt_test_flags & FLAG_AUDIO)         sxplayer_set_option(s, "avselect",      SXPLAYER_SELECT_AUDIO);

    for (i = 0; i < NB_ACTIONS; i++) {
        const int action = GET_ACTION(comb, i);
        if (!action)
            break;
        ret = actions_desc[action].func(s, opt_test_flags);
        if (ret < 0)
            break;
    }

    sxplayer_free(&s);
    return ret;
}
Exemplo n.º 6
0
static void
pref_view_sidebar_changed (GSettings  *settings,
		  	   const char *key,
		  	   gpointer    user_data)
{
	GApplication *application = user_data;

	g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR),
				   g_variant_new_boolean (g_settings_get_boolean (settings, PREF_UI_VIEW_SIDEBAR)));
	update_app_menu_sensitivity (application);
}
Exemplo n.º 7
0
static void
pref_list_mode_changed (GSettings  *settings,
			const char *key,
			gpointer    user_data)
{
	GApplication *application = user_data;

	g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE),
				   g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE,
						         g_settings_get_enum (settings, PREF_LISTING_LIST_MODE))->value_nick));
	update_app_menu_sensitivity (application);
}
Exemplo n.º 8
0
static int has_dup(uint64_t comb)
{
    int i;
    uint64_t actions = 0;

    for (i = 0; i < NB_ACTIONS; i++) {
        const int action = GET_ACTION(comb, i);
        if (!action)
            break;
        if (actions & (1<<action))
            return 1;
        actions |= 1 << action;
    }
    return 0;
}
Exemplo n.º 9
0
static void print_comb_name(uint64_t comb, int opt_test_flags)
{
    int i;

    printf(":: test-%s-", (opt_test_flags & FLAG_AUDIO) ? "audio" : "video");
    if (opt_test_flags & FLAG_SKIP)          printf("skip-");
    if (opt_test_flags & FLAG_TRIM_DURATION) printf("trimdur-");
    for (i = 0; i < NB_ACTIONS; i++) {
        const int action = GET_ACTION(comb, i);
        if (!action)
            break;
        printf("%s%s", i ? "-" : "", actions_desc[action].name);
    }
    printf(" (comb=0x%"PRIx64")\n", comb);
}
Exemplo n.º 10
0
/**
* WARNING: This function actually deletes a craft recipe.
*
* @param char_data *ch The person doing the deleting.
* @param craft_vnum vnum The vnum to delete.
*/
void olc_delete_craft(char_data *ch, craft_vnum vnum) {
	void cancel_gen_craft(char_data *ch);
	void remove_craft_from_table(craft_data *craft);
	
	craft_data *craft;
	char_data *iter;
	
	if (!(craft = craft_proto(vnum))) {
		msg_to_char(ch, "There is no such craft %d.\r\n", vnum);
		return;
	}
	
	if (HASH_COUNT(craft_table) <= 1) {
		msg_to_char(ch, "You can't delete the last craft.\r\n");
		return;
	}
	
	// find players who are crafting it and stop them (BEFORE removing from table)
	for (iter = character_list; iter; iter = iter->next) {
		if (!IS_NPC(iter) && GET_ACTION(iter) == ACT_GEN_CRAFT && GET_ACTION_VNUM(iter, 0) == GET_CRAFT_VNUM(craft)) {
			msg_to_char(iter, "The craft you were making has been deleted.\r\n");
			cancel_gen_craft(iter);
		}
	}
	
	// remove from table -- nothing else to check here
	remove_craft_from_table(craft);

	// save index and craft file now
	save_index(DB_BOOT_CRAFT);
	save_library_file_for_vnum(DB_BOOT_CRAFT, vnum);
	
	syslog(SYS_OLC, GET_INVIS_LEV(ch), TRUE, "OLC: %s has deleted craft recipe %d", GET_NAME(ch), vnum);
	msg_to_char(ch, "Craft recipe %d deleted.\r\n", vnum);
	
	free_craft(craft);
}
Exemplo n.º 11
0
void convert_mobs_to_disk(int zone_num)
{
    int i, rmob_num, zone, top;
    FILE *mob_file;
    char fname[64];
    struct char_data *mob;
    struct mob_attacks_data *attack;
    struct mob_equipment_data *equipment;
    struct mob_action_data *action;
    MPROG_DATA *mob_prog;

    zone = zone_table[zone_num].number;
    top = zone_table[zone_num].top;

    sprintf(fname, "%s/%i.mob", MOB_PREFIX, zone);

    if (!(mob_file = fopen(fname, "w"))) {
        mudlog("SYSERR: OLC: Cannot open mob file!", 'G', COM_BUILDER, TRUE);
        return;
    }

    /*. Seach database for mobs in this zone and save em .*/
    for (i = zone * 100; i <= top; i++) {
        rmob_num = real_mobile(i);

        if (rmob_num != -1) {
            if (fprintf(mob_file, "#%d\n", i) < 0) {
                mudlog("SYSERR: OLC: Cannot write mob file!\r\n", 'G', COM_BUILDER, TRUE);
                fclose(mob_file);
                return;
            }

            mob = (mob_proto + rmob_num);
            attack = GET_ATTACKS(mob);
            equipment = GET_EQUIP(mob);
            action = GET_ACTION(mob);
            mob_prog = mob_index[rmob_num].mobprogs;

            /*. Clean up strings .*/
            strcpy(buf1, GET_LDESC(mob));
            strip_string(buf1);
            if (GET_DDESC(mob)) {
                strcpy(buf2, GET_DDESC(mob));
                strip_string(buf2);
            } else
                strcpy(buf2, "");

            fprintf(mob_file, "%s~\n"
                    "%s~\n"
                    "%s~\n"
                    "%s~\n"
                    "%ld %ld %i X\n"
                    "%d %d %i %dd%d+%d %dd%d+%d\n"
                    "%d %d\n" /*. Gold & Exp are longs in my mud, ignore any warning .*/
                    "%d %d %d %d %d %d\n", GET_ALIAS(mob), GET_SDESC(mob), buf1, buf2, MOB_FLAGS(mob), AFF_FLAGS(mob), GET_ALIGNMENT(mob), GET_LEVEL(mob), GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob), GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob), GET_DAMROLL(mob), GET_GOLD(mob), GET_EXP(mob), GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob), GET_CLASS(mob), GET_RACE(mob), GET_SIZE(mob));

            while (attack) {
                fprintf(mob_file, "T %d %dd%d+%d %d\n", attack->attacks, attack->nodice, attack->sizedice, attack->damroll, attack->attack_type);
                attack = attack->next;
            }

            while (action) {
                fprintf(mob_file, "A %d %d %s\n", action->chance, action->minpos, action->action);
                action = action->next;
            }

            while (equipment) {
                fprintf(mob_file, "E %d %d %d %d\n", equipment->pos, equipment->chance, equipment->vnum, equipment->max);
                equipment = equipment->next;
            }

            /*. Deal with Extra stats in case they are there .*/
            if ((GET_STR(mob) != 11) && (GET_STR(mob) < 19))
                fprintf(mob_file, "Str: %d\n", (GET_STR(mob) * 5));
            else if ((GET_STR(mob) > 18) && (GET_STR(mob) != 50))
                fprintf(mob_file, "Str: 100\n");
            if ((GET_DEX(mob) != 11) && (GET_DEX(mob) < 19)) {
                fprintf(mob_file, "Dex: %d\n", (GET_DEX(mob) * 5));
                fprintf(mob_file, "Agi: %d\n", (GET_DEX(mob) * 5));
            } else if ((GET_DEX(mob) > 18) && (GET_DEX(mob) != 50)) {
                fprintf(mob_file, "Dex: 100\n");
                fprintf(mob_file, "Agi: 100\n");
            }
            if ((GET_INT(mob) != 11) && (GET_INT(mob) < 19))
                fprintf(mob_file, "Int: %d\n", (GET_INT(mob) * 5));
            else if ((GET_INT(mob) > 18) && (GET_INT(mob) != 50))
                fprintf(mob_file, "Int: 100\n");
            if ((GET_WIS(mob) != 11) && (GET_WIS(mob) < 19))
                fprintf(mob_file, "Wis: %d\n", (GET_WIS(mob) * 5));
            else if ((GET_WIS(mob) > 18) && (GET_WIS(mob) != 50))
                fprintf(mob_file, "Wis: 100\n");
            if ((GET_CON(mob) != 11) && (GET_CON(mob) < 19))
                fprintf(mob_file, "Con: %d\n", (GET_CON(mob) * 5));
            else if ((GET_CON(mob) > 18) && (GET_CON(mob) != 50))
                fprintf(mob_file, "Con: 100\n");

            /*. Deal with Mob Progs .*/
            while (mob_prog) {
                switch (mob_prog->type) {
                case IN_FILE_PROG:
                    fprintf(mob_file, ">in_file_prog");
                    break;
                case ACT_PROG:
                    fprintf(mob_file, ">act_prog");
                    break;
                case SPEECH_PROG:
                    fprintf(mob_file, ">speech_prog");
                    break;
                case RAND_PROG:
                    fprintf(mob_file, ">rand_prog");
                    break;
                case FIGHT_PROG:
                    fprintf(mob_file, ">fight_prog");
                    break;
                case HITPRCNT_PROG:
                    fprintf(mob_file, ">hitprcnt_prog");
                    break;
                case DEATH_PROG:
                    fprintf(mob_file, ">death_prog");
                    break;
                case ENTRY_PROG:
                    fprintf(mob_file, ">entry_prog");
                    break;
                case GREET_PROG:
                    fprintf(mob_file, ">greet_prog");
                    break;
                case ALL_GREET_PROG:
                    fprintf(mob_file, ">all_greet_prog");
                    break;
                case GIVE_PROG:
                    fprintf(mob_file, ">give_prog");
                    break;
                case BRIBE_PROG:
                    fprintf(mob_file, ">bribe_prog");
                    break;
                case SHOUT_PROG:
                    fprintf(mob_file, ">shout_prog");
                    break;
                case HOLLER_PROG:
                    fprintf(mob_file, ">holler_prog");
                    break;
                case TELL_PROG:
                    fprintf(mob_file, ">tell_prog");
                    break;
                case TIME_PROG:
                    fprintf(mob_file, ">time_prog");
                    break;
                }
                strcpy(buf1, mob_prog->arglist);
                strip_string(buf1);
                strcpy(buf2, mob_prog->comlist);
                strip_string(buf2);
                fprintf(mob_file, " %s~\n%s", buf1, buf2);
                mob_prog = mob_prog->next;
                if (!mob_prog)
                    fprintf(mob_file, "~\n|\n");
                else
                    fprintf(mob_file, "~\n");
            }
        }
    }
    fclose(mob_file);
}