void dialogs::show_stage_dialog()
{
    //std::cout << "DEBUG - dialogs::show_stage_dialog::stage: " << stage << ", player_n: " << (game_config.selected_player) << std::endl;
    if (strlen(stage_data.intro_dialog.face_graphics_filename) <= 0) {
        return;
    }

    if (strlen(stage_data.intro_dialog.line1[0]) <= 0) {
        return;
    }

    std::string lines[3];
    for (int i=0; i<3; i++) {
        lines[i] = std::string(stage_data.intro_dialog.line1[i]);
    }
    show_dialog(stage_data.intro_dialog.face_graphics_filename, stage_data.intro_dialog.top_side, lines, true);
    for (int i=0; i<3; i++) {
        lines[i] = std::string(stage_data.intro_dialog.answer1[game_save.selected_player][i]);
    }
    show_dialog(game_data.players[game_save.selected_player].face_filename, stage_data.intro_dialog.top_side, lines, true); /// @TODO: create "extern" for player number
    if (strlen(stage_data.intro_dialog.line2[0]) > 0) {
        for (int i=0; i<3; i++) {
            lines[i] = std::string(stage_data.intro_dialog.line2[i]);
        }
        show_dialog(stage_data.intro_dialog.face_graphics_filename, stage_data.intro_dialog.top_side, lines, true);
    }
}
void dialogs::show_boss_dialog()
{
    if (strlen(stage_data.intro_dialog.face_graphics_filename) <= 0) {
        return;
    }
    std::string lines[3];
    for (int i=0; i<3; i++) {
        lines[i] = std::string(stage_data.boss_dialog.line1[i]);
    }
    //std::cout << "stage: " << stage << ", boss_face: '" << stage_data.boss.face_graphics_filename << "'" << std::endl;
    if (strlen(stage_data.boss.face_graphics_filename) <= 0) {
        sprintf(stage_data.boss.face_graphics_filename, "%s", "dr_kanotus.png");
    }
    show_dialog(stage_data.boss.face_graphics_filename, stage_data.boss_dialog.top_side, lines, true);

    for (int i=0; i<3; i++) {
        lines[i] = std::string(stage_data.boss_dialog.answer1[game_save.selected_player][i]);
    }

    if (lines[0].size() > 0) {
        show_dialog(game_data.players[game_save.selected_player].face_filename, stage_data.boss_dialog.top_side, lines, true); /// @TODO: create "extern" for player number
    } else {
        return;
    }

    if (strlen(stage_data.boss_dialog.line2[0]) > 0) {
        for (int i=0; i<3; i++) {
            lines[i] = std::string(stage_data.boss_dialog.line2[i]);
        }
        show_dialog(stage_data.boss.face_graphics_filename, stage_data.boss_dialog.top_side, lines, true);
    }
}
Esempio n. 3
0
void loadgame::load_game()
{
	show_dialog(false, false);

	if(filename_ != "")
		throw game::load_game_exception(filename_, show_replay_, cancel_orders_, select_difficulty_, difficulty_);
}
Esempio n. 4
0
// Called only by play_controller to handle in-game attempts to load. Instead of returning true,
// throws a "load_game_exception" to signal a resulting load game request.
bool loadgame::load_game()
{
	if (!gui_.video().faked()) {
		show_dialog(false, false);
	}

	if(filename_.empty()) {
		return false;
	}

	// Confirm the integrity of the file before throwing the exception.
	// Use the summary in the save_index for this.

	const config & summary = save_index_manager.get(filename_);

	if (summary["corrupt"].to_bool(false)) {
		gui2::show_error_message(gui_.video(),
				_("The file you have tried to load is corrupt: '"));
		return false;
	}

	if (!loadgame::check_version_compatibility(summary["version"].str(), gui_.video())) {
		return false;
	}

	throw game::load_game_exception(filename_, show_replay_, cancel_orders_, select_difficulty_, difficulty_, true);
}
Esempio n. 5
0
void
nautilus_report_error_setting_permissions (NautilusFile *file,
                                           GError       *error,
                                           GtkWindow    *parent_window)
{
    g_autofree char *truncated_name = NULL;
    g_autofree char *truncated_error_message = NULL;
    g_autofree char *message = NULL;

    if (error == NULL)
    {
        return;
    }

    truncated_name = get_truncated_name_for_file (file);

    truncated_error_message = eel_str_middle_truncate (error->message,
                                                       MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
    message = g_strdup_printf (_("Sorry, could not change the permissions of “%s”: %s"),
                               truncated_name, truncated_error_message);

    show_dialog (_("The permissions could not be changed."),
                 message,
                 parent_window,
                 GTK_MESSAGE_ERROR);
}
Esempio n. 6
0
void loadgame::load_multiplayer_game()
{
	show_dialog(false, false);

	if (filename_.empty())
		throw load_game_cancelled_exception();

	std::string error_log;
	{
		cursor::setter cur(cursor::WAIT);
		log_scope("load_game");

		manager::read_save_file(filename_, load_config_, &error_log);
		copy_era(load_config_);

		gamestate_ = game_state(load_config_);
	}

	if(!error_log.empty()) {
		gui2::show_error_message(gui_.video(),
				_("The file you have tried to load is corrupt: '") +
				error_log);
		throw load_game_cancelled_exception();
	}

	if(gamestate_.classification().campaign_type != "multiplayer") {
		gui2::show_message(gui_.video(), "", _("This is not a multiplayer save"));
		throw load_game_cancelled_exception();
	}

	check_version_compatibility();
}
Esempio n. 7
0
bool loadgame::load_multiplayer_game()
{
	show_dialog(false, false);

	if (filename_.empty())
		return false;

	std::string error_log;
	{
		cursor::setter cur(cursor::WAIT);
		log_scope("load_game");

		read_save_file(filename_, load_config_, &error_log);
		copy_era(load_config_);

		gamestate_.set_data(load_config_);
	}

	if(!error_log.empty()) {
		gui2::show_error_message(gui_.video(),
				_("The file you have tried to load is corrupt: '") +
				error_log);
		return false;
	}

	if(gamestate_.classification().campaign_type != game_classification::CAMPAIGN_TYPE::MULTIPLAYER) {
		gui2::show_transient_error_message(gui_.video(), _("This is not a multiplayer save."));
		return false;
	}

	return check_version_compatibility();
}
int
main(int argc, char** argv)
{
	gchar* start_page = NULL;

	GOptionEntry option_entries[] = {
		{
			"show-page",
			'p',
			G_OPTION_FLAG_IN_MAIN,
			G_OPTION_ARG_STRING,
			&start_page,
			/* TRANSLATORS: don't translate the terms in brackets */
			N_("Specify the name of the page to show (internet|multimedia|system|a11y)"),
			N_("page")
		},
		{NULL}
	};

	GOptionContext* context = g_option_context_new(_("- MATE Default Applications"));
	g_option_context_add_main_entries(context, option_entries, GETTEXT_PACKAGE);

	capplet_init(context, &argc, &argv);

	MateDACapplet* capplet = g_new0(MateDACapplet, 1);

	show_dialog(capplet, start_page);
	g_free(start_page);

	gtk_main();

	return 0;
}
Esempio n. 9
0
void loadgame::load_game()
{
	show_dialog(false, false);

	if(filename_ != "")
		throw game::load_game_exception(filename_, show_replay_, false);
}
Esempio n. 10
0
void Phone_item::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsItem::mouseReleaseEvent(event);
    update();

    if(event->button() == Qt::RightButton)
        emit show_dialog();
}
Esempio n. 11
0
void loadgame::load_game(
		  const std::string& filename
		, const bool show_replay
		, const bool cancel_orders
		, const bool select_difficulty
		, const std::string& difficulty)
{
	filename_ = filename;
	difficulty_ = difficulty;
	select_difficulty_ = select_difficulty;

	if (filename_.empty()){
		show_dialog(show_replay, cancel_orders);
	}
	else{
		show_replay_ = show_replay;
		cancel_orders_ = cancel_orders;
	}

	if (filename_.empty())
		throw load_game_cancelled_exception();

	if (select_difficulty_)
		show_difficulty_dialog();

	std::string error_log;
	read_save_file(filename_, load_config_, &error_log);

	convert_old_saves(load_config_);

	if(!error_log.empty()) {
        try {
		    gui2::show_error_message(gui_.video(),
				    _("Warning: The file you have tried to load is corrupt. Loading anyway.\n") +
				    error_log);
        } catch (utf8::invalid_utf8_exception&) {
		    gui2::show_error_message(gui_.video(),
				    _("Warning: The file you have tried to load is corrupt. Loading anyway.\n") +
                    std::string("(UTF-8 ERROR)"));
        }
	}

	if (!difficulty_.empty()){
		load_config_["difficulty"] = difficulty_;
	}
#if 0
	gamestate_.classification().campaign_define = load_config_["campaign_define"].str();
	gamestate_.classification().campaign_type = lexical_cast_default<game_classification::CAMPAIGN_TYPE> (load_config_["campaign_type"].str(), game_classification::SCENARIO);
	gamestate_.classification().campaign_xtra_defines = utils::split(load_config_["campaign_extra_defines"]);
	gamestate_.classification().version = load_config_["version"].str();
	gamestate_.classification().difficulty = load_config_["difficulty"].str();
#else
	// read classification to for loading the game_config config object.
	gamestate_.classification() = game_classification(load_config_);
#endif
	check_version_compatibility();

}
Esempio n. 12
0
static void run(const gchar G_GNUC_UNUSED *nome, gint nparams, const GimpParam * params, gint *nretvals, GimpParam ** retparams)
{
	static GimpParam ret[1];
        GimpPDBStatusType* status;
	GimpDrawable* drawable;

	param_type p = VIZ4;

	*nretvals = 1;
	*retparams = ret;

	ret[0].type = GIMP_PDB_STATUS;
	status = (GimpPDBStatusType*) &(ret[0].data.d_status);

	*status = GIMP_PDB_CALLING_ERROR;

	drawable = gimp_drawable_get(params[2].data.d_drawable);
	
	if (!gimp_get_data(nome, &p))
		p = VIZ4;

	switch (params[0].data.d_int32)
	{
		case GIMP_RUN_INTERACTIVE:
			if (!show_dialog(&p))
			{
				ret[0].data.d_status = GIMP_PDB_CANCEL;
				return;
			}
			break;
		case GIMP_RUN_WITH_LAST_VALS:
			break;
		case GIMP_RUN_NONINTERACTIVE:
			if (nparams != 4)
			{
				/* retorna o erro de chamadoa para o gimp */
				ret[0].data.d_status = GIMP_PDB_CALLING_ERROR;
				return;
			}

			p = params[3].data.d_int8;
			break;
		default:
			g_error("programa no lugar errado");
			ret[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
			return;
	}
	gimp_set_data(nome, &p, sizeof(param_type));

	*status = execute_plugin(drawable, nome, &p);

	ret[0].data.d_status = GIMP_PDB_SUCCESS;
	return;
}
Esempio n. 13
0
HRESULT notification_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
{
	if(!wcscmp(action, L"alert") || !wcscmp(action, L"confirm"))
		return show_dialog(callback_id, args);
	if (!wcscmp(action, L"vibrate"))
		return vibrate(callback_id, args);
	if (!wcscmp(action, L"beep"))
		return beep(callback_id, args);

	return DISP_E_MEMBERNOTFOUND;
}
Esempio n. 14
0
void
nautilus_report_error_setting_group (NautilusFile *file,
                                     GError       *error,
                                     GtkWindow    *parent_window)
{
    g_autofree char *truncated_name = NULL;
    g_autofree char *message = NULL;

    if (error == NULL)
    {
        return;
    }

    truncated_name = get_truncated_name_for_file (file);

    if (error->domain == G_IO_ERROR)
    {
        switch (error->code)
        {
            case G_IO_ERROR_PERMISSION_DENIED:
            {
                message = g_strdup_printf (_("You do not have the permissions necessary to change the group of “%s”."),
                                           truncated_name);
            }
            break;

            default:
            {
            }
            break;
        }
    }

    if (message == NULL)
    {
        g_autofree char *truncated_error_message = NULL;

        truncated_error_message = eel_str_middle_truncate (error->message,
                                                           MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);

        /* We should invent decent error messages for every case we actually experience. */
        g_warning ("Hit unhandled case %s:%d in nautilus_report_error_setting_group",
                   g_quark_to_string (error->domain), error->code);
        /* fall through */
        message = g_strdup_printf (_("Sorry, could not change the group of “%s”: %s"), truncated_name,
                                   truncated_error_message);
    }


    show_dialog (_("The group could not be changed."), message, parent_window, GTK_MESSAGE_ERROR);
}
Esempio n. 15
0
	// handler of custom functions for the CSSS! engine
    virtual BOOL on_script_call(HELEMENT he, LPCSTR name, UINT argc, json::value* argv, json::value& retval) 
    { 
		  if( aux::streq(name, "show") )
        {
          show_dialog(he);
          return TRUE;
        }
		  else if( aux::streq(name, "hide") )
        {
		      hide_dialog(he);
          return TRUE;
        }
        return FALSE; 
    }      
Esempio n. 16
0
/*
void armor_edit::fill_armor_abilities() {
    std::string arm_abilities[] = {"Super-Shot", "Laser-Beam", "Always-Charged", "Freeze"};
    std::string legs_abilities[] = {"Double Jump", "Air-Dash", "Wall-Grab"};
    std::string body_abilities[] = {"Half-Damage", "Extended Imunnity", "Spikes Immune", "No Push-Back"};
 */
void dialogs::showGotArmorDialog(e_ARMOR_PIECES armor_type)
{
    std::string type_str = "???";
    std::string ability_str = "???";

    //std::cout << ">> showGotArmorDialog - p4.arms: " << game_data.armor_pieces[game_save.selected_player].special_ability[ARMOR_ARMS] << std::endl;

    int type = game_data.armor_pieces[armor_type].special_ability[game_save.selected_player];
    //std::cout << "player: " << game_save.selected_player << ", armor_type: " << armor_type << ", armor.ability: " << type << std::endl;
    if (armor_type == ARMOR_ARMS) {
        type_str = "THESE IMPROVED ARMS WILL";
        if (type == ARMOR_ABILITY_ARMS_ALWAYSCHARGED) {
            ability_str = "ALWAYS FIRE CHARGED";
        } else if (type == ARMOR_ABILITY_ARMS_LASERBEAM) {
            ability_str = "CHARGE A LASER BEAM";
        } else if (type == ARMOR_ABILITY_ARMS_SUPERSHOT) {
            ability_str = "FIRE A SUPER-SHOT!";
        } else if (type == ARMOR_ABILITY_ARMS_MISSILE) {
            ability_str = "THROW A HADOUKEN.";
        }
    } else if (armor_type == ARMOR_LEGS) {
        if (type == ARMOR_ABILITY_LEGS_AIRDASH) {
            type_str = "THESE LIGHTER LEGS";
            ability_str = "DASH IN MIDDLE-AIR.";
        } else if (type == ARMOR_ABILITY_LEGS_DOUBLEJUMP) {
            type_str = "THESE LIGHTER LEGS";
            ability_str = "EXECUTE A DOUBLE JUMP.";
        } else if (type == ARMOR_ABILITY_LEGS_SHORYUKEN) {
            type_str = "HOLD UP AND DASH";
            ability_str = "TO SHURYUKEN!";
        }
    } else {
        type_str = "THIS FORTIFIED BODY WILL";
        if (type == ARMOR_ABILITY_BODY_EXTENDEDIMMUNITY) {
            ability_str = "BE INTANGIBLE FOR MORE TIME.";
        } else if (type == ARMOR_ABILITY_BODY_HALFDAMAGE) {
            ability_str = "TAKE HALF DAMAGE.";
        } else if (type == ARMOR_ABILITY_BODY_NOPUSHBACK) {
            ability_str = "RESIST PUSH-BACK.";
        } else if (type == ARMOR_ABILITY_BODY_SPIKESIMMMUNE) {
            ability_str = "RESIST SPIKES.";
        }
    }



    std::string lines[] = {type_str, "GIVE YOU THE ABILITY TO", ability_str};
    show_dialog("canotus_face.png", true, lines, true);
}
Esempio n. 17
0
static void
gtk_file_chooser_native_show (GtkNativeDialog *native)
{
  GtkFileChooserNative *self = GTK_FILE_CHOOSER_NATIVE (native);

  self->mode = MODE_FALLBACK;

#ifdef GDK_WINDOWING_WIN32
  if (gtk_file_chooser_native_win32_show (self))
    self->mode = MODE_WIN32;
#endif

  if (self->mode == MODE_FALLBACK)
    show_dialog (self);
}
Esempio n. 18
0
void save_load(GtkWindow* parent)
{
	gchar * uri = show_dialog(parent, GTK_FILE_CHOOSER_ACTION_OPEN);

	if (uri) {
		const gchar * frz_file = game_state_get_frz_file();
		gchar * frz_uri = gnome_vfs_get_uri_from_local_path(frz_file);
		show_result(copy_file(uri, frz_uri), parent, "Game loaded");
		g_free(frz_uri);
	}

	if (cur_save_uri) {
		g_free(cur_save_uri);
	}
	cur_save_uri = uri;
}
Esempio n. 19
0
void ui_dialog(int dialog_text_id, int button_text_id, float hide_after)
{
    set_dialog_text(dialog_text_id);

    if (button_text_id != UI_BUTTON_NONE) {
        set_button_text(button_text_id);
        show_button();
    }
    else {
        hide_button();
    }

    show_dialog();

    if (hide_after > 0) {
        hide_dialog_later(hide_after);
    }
}
Esempio n. 20
0
void save_save_as(GtkWindow* parent)
{
	gchar * uri = show_dialog(parent, GTK_FILE_CHOOSER_ACTION_SAVE);

	if (uri) {
		const gchar * frz_file = game_state_get_frz_file();
		gchar * frz_uri = gnome_vfs_get_uri_from_local_path(frz_file);
		gboolean res = show_result(copy_file(frz_uri, uri), parent, "Game saved");
		g_free(frz_uri);

		if (!res) return;

		if (cur_save_uri) {
			g_free(cur_save_uri);
		}
		cur_save_uri = uri;
	}
}
int main (int argc, char** argv)
{
    MateDACapplet* capplet;

    gchar* start_page = NULL;

    GOptionContext* context;
    GOptionEntry option_entries[] = {
		{
			"show-page",
			'p',
			G_OPTION_FLAG_IN_MAIN,
			G_OPTION_ARG_STRING,
			&start_page,
			/* TRANSLATORS: don't translate the terms in brackets */
			N_("Specify the name of the page to show (internet|multimedia|system|a11y)"),
			N_("page")
		},
		{NULL}
    };

    context = g_option_context_new(_("- MATE Default Applications"));
    g_option_context_add_main_entries (context, option_entries, GETTEXT_PACKAGE);

    capplet_init (context, &argc, &argv);

    capplet = g_new0(MateDACapplet, 1);
    capplet->mateconf = mateconf_client_get_default();
    mateconf_client_add_dir(capplet->mateconf, "/desktop/mate/url-handlers", MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL);
    mateconf_client_add_dir(capplet->mateconf, "/desktop/mate/applications", MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL);

    mate_da_xml_load_list(capplet);

    show_dialog(capplet, start_page);
    g_free(start_page);

    gtk_main();

    g_object_unref(capplet->mateconf);

    mate_da_xml_free(capplet);

    return 0;
}
Esempio n. 22
0
void loadgame::load_game(
		  const std::string& filename
		, const bool show_replay
		, const bool cancel_orders)
{
	filename_ = filename;

	if (filename_.empty()){
		show_dialog(show_replay, cancel_orders);
	}
	else{
		show_replay_ = show_replay;
		cancel_orders_ = cancel_orders;
	}

	if (filename_.empty())
		throw load_game_cancelled_exception();

	std::string error_log;
	manager::read_save_file(filename_, load_config_, &error_log);

	if(!error_log.empty()) {
        try {
		    gui2::show_error_message(gui_.video(),
				    _("Warning: The file you have tried to load is corrupt. Loading anyway.\n") +
				    error_log);
        } catch (utils::invalid_utf8_exception&) {
		    gui2::show_error_message(gui_.video(),
				    _("Warning: The file you have tried to load is corrupt. Loading anyway.\n") +
                    std::string("(UTF-8 ERROR)"));
        }
	}

	gamestate_.classification().difficulty = load_config_["difficulty"].str();
	gamestate_.classification().campaign_define = load_config_["campaign_define"].str();
	gamestate_.classification().campaign_type = load_config_["campaign_type"].str();
	gamestate_.classification().campaign_xtra_defines = utils::split(load_config_["campaign_extra_defines"]);
	gamestate_.classification().version = load_config_["version"].str();

	check_version_compatibility();

}
Esempio n. 23
0
void loadgame::load_game(std::string& filename, bool show_replay, bool allow_network, hero_map& heros, hero_map* heros_start)
{
	filename_ = filename;

	if (filename_.empty()){
		show_dialog(show_replay, allow_network);
	} else {
		show_replay_ = show_replay;
	}

	if (filename_.empty())
		throw load_game_cancelled_exception();

	std::string error_log;
	manager::read_save_file(filename_, NULL, &load_config_, heros_start, &replay_data_, &heros, &error_log);

	if(!error_log.empty()) {
        try {
		    gui2::show_error_message(gui_.video(),
				    _("Warning: The file you have tried to load is corrupt. Loading anyway.\n") +
				    error_log);
        } catch (utils::invalid_utf8_exception&) {
		    gui2::show_error_message(gui_.video(),
				    _("Warning: The file you have tried to load is corrupt. Loading anyway.\n") +
                    std::string("(UTF-8 ERROR)"));
        }
	}

	gamestate_.classification().create = load_config_["create"].to_long();
	gamestate_.classification().duration = load_config_["duration"].to_int();
	gamestate_.classification().hash = load_config_["hash"].to_int();
	gamestate_.classification().campaign_define = load_config_["campaign_define"].str();

	gamestate_.classification().campaign = load_config_["campaign"].str();
	gamestate_.classification().campaign_type = load_config_["campaign_type"].str();

	gamestate_.classification().version = load_config_["version"].str();

	check_version_compatibility();

}
Esempio n. 24
0
// seg000:23F4
void __pascal far show_copyprot(int where) {
#ifdef USE_COPYPROT
	char sprintf_temp[140];
	if (current_level != 15) return;
	if (where) {
		if (text_time_remaining || is_cutscene) return;
		text_time_total = 1188;
		text_time_remaining = 1188;
		is_show_time = 0;
		snprintf(sprintf_temp, sizeof(sprintf_temp),
			"WORD %d LINE %d PAGE %d",
			copyprot_word[copyprot_idx], copyprot_line[copyprot_idx], copyprot_page[copyprot_idx]);
		display_text_bottom(sprintf_temp);
	} else {
		snprintf(sprintf_temp, sizeof(sprintf_temp),
			"Drink potion matching the first letter of Word %d on Line %d\n"
			"of Page %d of the manual.",
			copyprot_word[copyprot_idx], copyprot_line[copyprot_idx], copyprot_page[copyprot_idx]);
		show_dialog(sprintf_temp);
	}
#endif
}
Esempio n. 25
0
static void
add_dispatch_operation_cb (TpSimpleApprover *self,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    TpChannelDispatchOperation *cdo,
    TpAddDispatchOperationContext *context,
    gpointer user_data)
{
    TpContact *target = NULL;
    GList *l;

    (void)account;      /* suppress unused-parameter warning */
    (void)connection;   /* suppress unused-parameter warning */
    (void)user_data;    /* suppress unused-parameter warning */

    g_print ("Approving this batch of channels:\n");

    for (l = channels; l != NULL; l = g_list_next (l))
    {
        TpChannel *channel = l->data;

        if (TP_IS_DBUS_TUBE_CHANNEL (channel))
        {
            target = tp_channel_get_target_contact (channel);
            break;
        }
    }

    if (target == NULL)
    {
        g_critical ("Hmm. No 1-1 D-Bus tube in cdo %s, so why did we get it?",
            tp_proxy_get_object_path (cdo));
        g_return_if_reached ();
    }

    tp_add_dispatch_operation_context_accept (context);
    show_dialog (self, cdo, target);
}
Esempio n. 26
0
mainWindow::mainWindow() : QMainWindow(),
    ui(new Ui::MainWindow)
{
    this->setMinimumSize(1000,500);
    // Creating the general UI
    ui->setupUi(this);

    // Making last minute adjustments and
    // initializing some parts of the UI
    ui->tabWidget->setCurrentIndex(0);
    ui->fileName->setText("log_file");
    ui->actionDisconnect->setEnabled(false);

    // Creating the logger file instance
    log = new QFile();

    // Creating the session file instance
    session = new QFile("session.dat");


    // Creating the QVector of double needed to store the graphs
    // points
    y[0] = new QVector<double>(2);
    x[0] = new QVector<double>(2);

    x[1] = new QVector<double>(200);

    y[1] = new QVector<double>(200);
    y[2] = new QVector<double>(200);
    y[3] = new QVector<double>(200);

    y[4] = new QVector<double>(200);
    y[5] = new QVector<double>(200);
    y[6] = new QVector<double>(200);

    y[7] = new QVector<double>(200);

    // The SettingsDialog instance handles the serial port configuration
    // window
    settings = new SettingsDialog();
    file_viewer = new FileViewer();

    // The Protocole instance handles the communication through the selected
    // serial port and parses the data received through a RegEx string
    protocole = new Protocole();


    // Now that everything's ready, try restoring
    // an existing session
    restoreSession();

    // Connecting all the commands button
    QSignalMapper * cmdMap = new QSignalMapper(this);

    connect(ui->cmdFreq,SIGNAL(clicked()),cmdMap,SLOT(map()));
    connect(ui->cmdBurst,SIGNAL(clicked()),cmdMap,SLOT(map()));
    connect(ui->cmdStream,SIGNAL(clicked()),cmdMap,SLOT(map()));
    cmdMap -> setMapping (ui->cmdFreq, "FRQ") ;
    cmdMap -> setMapping (ui->cmdBurst, "BST") ;
    cmdMap -> setMapping (ui->cmdStream, "STR") ;
    connect(cmdMap,SIGNAL(mapped(QString)),this,SLOT(sendCommandBox(QString)));

    // Connecting the buttons for RTC sync
    connect(ui->sendTime,SIGNAL(clicked()),this,SLOT(sendRTCTime()));
    connect(ui->getTime,SIGNAL(clicked()),this,SLOT(getRTCTime()));
    connect(ui->syncSysTime,SIGNAL(clicked()),this,SLOT(getSysTime()));

    // Connecting the button to fetch the last logged frames
    // into the console
    connect(ui->logUpdate,SIGNAL(clicked()),this,SLOT(update_c()));

    // Connecting the buttons used to connect to and configure
    // the serial port
    connect(ui->actionConnect, SIGNAL(clicked()), this, SLOT(openSerialPort()));
    connect(ui->actionDisconnect, SIGNAL(clicked()), this, SLOT(closeSerialPort()));
    connect(ui->actionConfigure, SIGNAL(clicked()), settings, SLOT(show()));
    connect(ui->cmdCustomSend,SIGNAL(clicked()),this,SLOT(sendCustomCommand()));

    connect(ui->applyLog, SIGNAL(clicked()),this,SLOT(applyLog()));


    logMap = new QSignalMapper(this);
    logMap->setMapping(ui->viewLog,logDirectory);
    connect(ui->viewLog,SIGNAL(clicked()),logMap,SLOT(map()));
    connect(logMap,SIGNAL(mapped(QString)),file_viewer,SLOT(show_dialog(QString)));

    // Connectring the button to change the log directory
    connect(ui->changeDirectory,SIGNAL(clicked()),this,SLOT(changeLogDirectory()));

    // Creating graphs instances by linking them to UI elements
    graph[0] = ui->graphXY;
    graph[1] = ui->graphXAxis;
    graph[2] = ui->graphYAxis;
    graph[3] = ui->graphZAxis;
    graph[4] = ui->gyroX;
    graph[5] = ui->gyroY;
    graph[6] = ui->gyroZ;
    graph[7] = ui->weightGraph;

    // The pen is used to draw a dot on XY graphs
    QPen pen;
    pen.setColor(QColor(229,115,115,255));
    pen.setWidth(10);
    pen.setCapStyle(Qt::RoundCap);
    // The line is used to draw classic graphs
    QPen line;
    line.setColor(QColor(25,118,210,255));
    line.setWidth(1);
    QPen line_red;
    line_red.setColor(QColor(210,25,118,255));
    line_red.setWidth(1);
    QPen line_green;
    line_green.setColor(QColor(118,210,25,255));
    line_green.setWidth(1);


    // Graph 1 to 6 stores the accelerometer and gyroscope
    // axis, and share similar settings.
    // Their label can be set directly in the next array
    QString label[16] = {
        "",
        "X","Y","Z",    // Accelerometer's three axis
        "X","Y","Z"     // Gyroscope's three axis
    };
    for(int i=1;i<8;i++) {
        // Only one curve on those graphs : axis/time
        graph[i]->addGraph();
        // The datas are stored in x[1] (time) and y[i] vectors
        graph[i]->graph(0)->setData(*x[1],*y[i]);
        graph[i]->graph(0)->setPen(line);
        // Setting the labels of each axis, as well
        // as the range
        graph[i]->xAxis->setLabel("t");
        graph[i]->yAxis->setLabel(label[i]);
        graph[i]->yAxis->setRange(-32000,32000);
        // The X Axis should display time (text)
        graph[i]->setLocale(QLocale(QLocale::English, QLocale::Canada));
        graph[i]->xAxis->setTickLabelType(QCPAxis::ltDateTime);
        graph[i]->xAxis->setDateTimeFormat("hh:mm:ss");
        graph[i]->xAxis->setDateTimeSpec(Qt::OffsetFromUTC);
        // Activating the zoom and drag interraction in vertical mode
        graph[i]->setInteraction(QCP::iRangeDrag, true);
        graph[i]->setInteraction(QCP::iRangeZoom, true);
        graph[i]->yAxis->axisRect()->setRangeDrag(Qt::Vertical);
        graph[i]->yAxis->axisRect()->setRangeZoom(Qt::Vertical);
    }
    graph[2]->graph(0)->setPen(line_green);
    graph[3]->graph(0)->setPen(line_red);
    graph[5]->graph(0)->setPen(line_green);
    graph[6]->graph(0)->setPen(line_red);

    graph[7]->yAxis->setRange(0,150);

    // Populating the XY graph
    // Only one curve on this graph : X axis /Y axis of accelerometer
    graph[0]->addGraph();
    // The datas are stored in x[0] and y[0] vectors
    graph[0]->graph(0)->setData(*x[0],*y[0]);
    // Draw a red dot
    graph[0]->graph(0)->setPen(pen);
    // Setting the labels of each axis, as well
    // as the range
    graph[0]->xAxis->setLabel("X");
    graph[0]->yAxis->setLabel("Y");
    graph[0]->xAxis->setRange(-10000,10000);
    graph[0]->yAxis->setRange(-10000,10000);
    // Activating the zoom and drag interraction in vertical and horizontal mode
    graph[0]->setInteraction(QCP::iRangeDrag, true);
    graph[0]->setInteraction(QCP::iRangeZoom, true);

    // For each graph, making the lines lighter in order to clean up the view
    for(int i=0;i<8;i++) {
        graph[i]->xAxis->setBasePen(QPen(QColor(195,195,195)));
        graph[i]->xAxis->setTickPen(QPen(QColor(195,195,195)));
        graph[i]->xAxis->setSubTickPen(QPen(QColor(195,195,195)));
        graph[i]->yAxis->setBasePen(QPen(QColor(195,195,195)));
        graph[i]->yAxis->setTickPen(QPen(QColor(195,195,195)));
        graph[i]->yAxis->setSubTickPen(QPen(QColor(195,195,195)));
    }

    // For every setting that should be saved, connecting the saveSession slot to
    // the state change signal
    connect(ui->appendDate,SIGNAL(stateChanged(int)),this,SLOT(saveSession()));
    connect(ui->logToFile,SIGNAL(stateChanged(int)),this,SLOT(saveSession()));
    connect(ui->fileName,SIGNAL(textChanged(QString)),this,SLOT(saveSession()));
    connect(ui->cmdValue,SIGNAL(valueChanged(int)),this,SLOT(saveSession()));
    connect(settings,SIGNAL(updated()),this,SLOT(saveSession()));

    // Addding Window's title
    setWindowTitle("Doctor's Orders Data Logger");



    // Creating a Timer for frame fetching
    serialFetch = new QTimer();
    serialFetch->setInterval(2);
    connect(serialFetch,SIGNAL(timeout()),protocole,SLOT(fetch()));

    // Creating a Timer for GUI update
    guiUpdate = new QTimer();
    guiUpdate->setInterval(50);
    connect(guiUpdate,SIGNAL(timeout()),this,SLOT(update()));

    // Connecting the serial port to the updateData slot
    connect(protocole,SIGNAL(updateData()),this,SLOT(updateData()));
}
Esempio n. 27
0
void View::about_dialog()
{
  show_dialog ("about_dialog");
}
void gui_show_info_dialog(const std::string& message, Gtk::Window* parent)
{
	show_dialog(message, "", parent, Gtk::MESSAGE_INFO, false);
}
Esempio n. 29
0
int get_vmem_info(char *string)
{
	char buffer[100 * 1024], buffer1[500];
	char dir1[50], dir2[50];
	int fd1, fd2;
	int bytes;
	int vmem;
	int i = 1, j, m;
	char *c[10000], *ch[500], *p, *buf[50];
	GtkTreeIter iter;
	char vmem_label_text[50];
	sprintf(dir1, "/proc/%s/maps", string);
	fd1 = open(dir1, O_RDONLY);
	if(fd1 == -1)
	{
		char *title = "错误1";
		char *content = "\n					打开文件失败				\n";
		show_dialog(title, content);
	}
	
	bytes = read(fd1, buffer, sizeof(buffer));
	if(bytes == 0 || bytes == sizeof(buffer))
	{
		char *title1 = "错误2";
		char *content1 = "\n				读取文件失败                \n";
		show_dialog(title1, content1);
	}

	close(fd1);
//	printf("%d\n", bytes); 
//	printf("%s", buffer);

	c[0] = strtok(buffer, "\n");
	i = 1;
//	printf("11111111111111111111111111111111111111111111111111111111111111111\n");
//	printf("%s\n", c[0]);
	while(p = strtok(NULL, "\n"))
	{
		c[i] = p;
//		printf("%d\n", i);
//		printf("%s\n", c[i]);
		i++;
//		printf("%d\n", i);
//		printf("%s\n", c[i]);
	}

	for(j = 0, m = 1; j < i; j++, m = 1)
	{
		ch[0] = strtok(c[j], " ");
		while(p = strtok(NULL, " "))
		{
			ch[m] = p;
//			printf("%d\n", m);
//			printf("%s\n", ch[m]);
			m++;
//			printf("%d\n", m);
//			printf("%s\n", ch[m]);
		}

		gtk_list_store_append(vmem_store, &iter);
		gtk_list_store_set(vmem_store, &iter,
						ADDRESS_COLUMN, ch[0],
						PERMS_COLUMN, ch[1],
						OFFSET_COLUMN, ch[2],
						DEV_COLUMN, ch[3],
						INODE_COLUMN, ch[4],
						NAME1_COLUMN, ch[5],
						-1);
	}

	sprintf(dir2, "/proc/%s/stat", string);
	
	fd2 = open(dir2, O_RDONLY);
	read(fd2, buffer1, sizeof(buffer1));
	close(fd2);

	buf[0] = strtok(buffer1, " ");
	i = 1;
	while(p = strtok(NULL, " "))
	{
		buf[i] = p;
		i++;
	}

	vmem = atoi(buf[22]);
	vmem = vmem / 1024;

	sprintf(vmem_label_text, "Virtual Memory Size: %d KB", vmem);

	gtk_label_set_text(GTK_LABEL(v_label), vmem_label_text);

	return 1;
}
void gui_show_info_dialog(const std::string& message, const std::string& sec_message,
		Gtk::Window* parent, bool sec_msg_markup)
{
	show_dialog(message, sec_message, parent, Gtk::MESSAGE_INFO, sec_msg_markup);
}