Exemplo n.º 1
0
void delete_cb(Fl_Widget*, void* ic)
{
	Icon* icon = (Icon*)ic;
	assert(icon != NULL);

	fl_ask(_("Delete %s ?"), icon->label().c_str());
}
Exemplo n.º 2
0
void JetpackUI::cb_clear(Fl_Menu_* o, void* v) 
{
	if (fl_ask("Are you sure you want to clear the current level?") == 0) { // NO
			return;
	}
	whoami(o)->m_editor->Clear();
}
Exemplo n.º 3
0
void window_callback(Fl_Widget*, void*) {
//    printf("window_callback entered, level %d\n", recurse++);
  if (!fl_ask("Are you sure you want to quit?")) {
//      printf("window_callback exited, level %d\n", --recurse);
    return;
  }
  exit(0);
}
Exemplo n.º 4
0
inline int moobyAsk(const char* message)
{
   int i = fl_ask(message);
#ifdef __LINUX__
   Fl::wait();
#endif
   return i;
}
Exemplo n.º 5
0
void delete_icon(Fl_Widget*, Icon *icon)
{
    if (fl_ask(_("Delete this icon?"))) 
    {
        icon->hide();
        Fl_String fname(icon->get_cfg()->filename());
        delete icon;
        if(remove(fname) < 0)
            fl_alert(_("Remove of the icon %s failed. You probably do not have write access to this file."), fname.c_str());
    }
}
Exemplo n.º 6
0
Arquivo: Main.cpp Projeto: aib/glito
void calibrate_param( Fl_Button* w, void* m ) {
    const int measureTime = 8; // 8 seconds
    static int frames = 16; // 16 frames per second
    if ( fl_ask( _("Do you want the program to calibrate the number\nof pixels to calculate for each frame?\n\n(Esc to cancel the process)") ) ) {
	const char* answer = fl_input( _("How many frames per second?"),
				       IS::translate(frames).c_str() );
	if ( answer ) {
	    frames = atoi(answer);
	    Glito* glito = (Glito*)m;
	    glito->state = CALIBRATE;
	    glito->calibrate( measureTime, frames );
	    glito->state = PREVIEW;
 	    glito->redraw();
	    const int index = w->parent()->find(*w);
	    Fl_Int_Input* input = (Fl_Int_Input*)w->parent()->child( index - 1 );
	    input->value( IS::translate(glito->pointsPerFrame).c_str() );
	}
    }
}
/* 実行する(OK(0))か否(NG(-1))かを返す */
int gtsfbro06cb_level::_rename_file_tif( int i_num, const char *ccp_old, char *cp_new )
{
	ST_DIR_OR_FILE_INFO *stp_dir_or_file;
	const char *ccp_dir, *ccp_new;
	char ca_msg[PTBL_PATH_MAX];
	char ca_path[PTBL_PATH_MAX];

	stp_dir_or_file = this->stp_dir_or_file_info(i_num);
	if (NULL == stp_dir_or_file) { return NG; }

	if (E_DIR_OR_FILE_IS_NOT_TRACEING_RGB_IMAGE ==
	stp_dir_or_file->e_type) {
		ccp_dir =cl_gts_gui.filinp_level_rgb_scan_dir->value();
	} else {
		ccp_dir =cl_gts_gui.filinp_level_dir->value();
	}

	/* Dialogのメッセージ生成 */
	snprintf(ca_msg,PTBL_PATH_MAX,"In\n %s\nRename File\n %s",
			ccp_dir,ccp_old);

	/* Dialogを使いユーザーによるDir名変更 */
	ccp_new = fl_input( ca_msg, ccp_old );

	/* ユーザーによるcancel */
	if (NULL == ccp_new) {
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 入力した名前のチェック-------------------------- */
	// cp_new[0] = '\0';
	sscanf(ccp_new,"%s",cp_new); /* space文字をとる */

	/* 空文字か変更なし */
	if (('\0' == cp_new[0]) || !strcmp( ccp_old,cp_new )) {
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 有効でない文字がある */
	if (NG == this->_is_valid_string( cp_new )) {
		snprintf( ca_msg,PTBL_PATH_MAX,
		"bad string.\n %s\ninclude bad character",
			cp_new);
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 同じ名前がある */
	if (NULL != this->stp_dir_or_file_search(cp_new)) {
		if (E_DIR_OR_FILE_IS_DIR ==
		this->stp_dir_or_file_search(cp_new)->e_type) {
			snprintf( ca_msg,PTBL_PATH_MAX,
			"Can not rename.\nDirectory\n %s\nis exist",
				cp_new);
		} else {
			snprintf( ca_msg,PTBL_PATH_MAX,
			"Can not rename.\nFile\n %s\nis exist",
				cp_new);
		}
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 拡張子の確認 */
	const char *ccp_n,*ccp_o;
	ccp_o = strrchr( ccp_old, '.' );
	ccp_n = strrchr( cp_new, '.' );
	if (	(NULL != ccp_o) && /* 元もと、拡張子があって */
		(	(NULL == ccp_n) || /* 拡張子がないか... */
			strcmp(ccp_o,ccp_n) /* あるいは違う拡張子名 */
		)
	) {
		snprintf(ca_msg,PTBL_PATH_MAX,
			"Do Not change extention\n %s",
			cp_new);
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}
	/* 接尾語".0000.tif"の確認 */
	if (NULL == this->ccp_num4_and_ext( cp_new )) {
		snprintf(ca_msg,PTBL_PATH_MAX,
			"Do Not change number or extention\n %s",
			cp_new);
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 新しいDirパス生成 */
	if (OK != this->i_path_dir_file( ccp_dir, cp_new )) {
		pri_funct_err_bttvr(
	 "Error : this->i_path_dir_file(%s,%s) returns NG",
			ccp_dir, cp_new
		);
		strcpy( cp_new,ccp_old );
		return NG;
	}
	strcpy( ca_path, this->cp_path() );

#if 0
	/* Dialogを使い実行確認 */
	snprintf(ca_msg,PTBL_PATH_MAX,
		"In\n %s\nRename File\n %s --> %s ok?",
		ccp_dir,ccp_old,cp_new
	);
	if (0 == fl_ask(ca_msg)) {
		strcpy( cp_new,ccp_old );
		return NG; /* ユーザーによるcancel */
	}
#endif

	/* 古いDirパス設定 */
	if (OK != this->i_path_dir_file( ccp_dir, ccp_old )) {
		pri_funct_err_bttvr(
	 "Error : this->i_path_dir_file(%s,%s) returns NG",
			ccp_dir, ccp_old
		);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 変更 */
	if (rename( this->cp_path(), ca_path )) {
		pri_funct_err_bttvr(
   "Error : rename(%s,%s) returns not zero",
			this->cp_path(), ca_path
		);
		/* rename()に失敗してもリスト再表示はする */
		strcpy( cp_new,ccp_old );
		return NG;
	}
	return OK;
}
Exemplo n.º 8
0
void cb_trace_files::cb_renumber(void)
{
	/* Openファイルのフルパスを得る */
	const std::string filepath = this->get_open_path( 1 );
	if (filepath.empty()) {
		fl_alert( "Not set Open Folder or File name" );
		return;
	}

	/* 連番ファイルの存在チェックして必要な情報に変える */
	std::string dpath , head , num , ext;
	int number=-1;
	std::vector<int> nums;
	ids::path::level_from_files(
		filepath ,dpath ,head ,num ,number ,ext ,nums
	);
	if (head.empty() || nums.size() <= 0) {
		fl_alert( "Not exist files" );
		return;
	}

	/* ユーザーから新しいStart番号を得る */
	const char* new_start_num_ptr = fl_input(
		"Enter New Start Number" ,std::to_string(nums.at(0)).c_str()
	);
	if (new_start_num_ptr == nullptr
	||  std::stoi(std::string(new_start_num_ptr))==nums.at(0)) {
		return; /* Cancel or 同じ名前なら何もしない */
	}
	const std::string new_start_num( new_start_num_ptr );

	/* 新しいStart番号との差 */
	const int diff_num = std::stoi(new_start_num) - nums.at(0);

	/* エラー数値をチェックしつつ番号を文字列に入れる */
	std::ostringstream numost;
	bool error_sw = false;
	for (auto nu : nums) {
		numost << nu + diff_num;
		numost << " ";
		if ( nu + diff_num < 0 || 9999 < nu + diff_num ) {
			error_sw = true;
		}
	}

	/* ゼロ以下数値があるとエラーメッセージダイオローグを出して終わる */
	if (error_sw) {
		std::string opa( this->get_open_path( nums.at(0) ) );
		std::string npa( this->get_open_path(
				nums.at(0) + diff_num ) );
		fl_alert(
"Error : Number need 0...9999 range\nFrom\n %s\nTo\n %s\nNumber List\n %s\n"
			,opa.c_str()
			,npa.c_str()
			,numost.str().c_str()
		);
		return;
	}

	/* ファイル毎名前を変更する */
	for (size_t ii=0; ii<nums.size() ; ++ii) {
		std::string opa( this->get_open_path( nums.at(ii) ) );
		std::string npa( this->get_open_path(
				nums.at(ii) + diff_num ) );
		/* 最初にこれでいいかユーザーに確認する */
		if (ii==0) {
			if (fl_ask(
"Renumber\nFrom\n %s\nTo\n %s\nNumber List\n %s\nOK?"
				,opa.c_str()
				,npa.c_str()
				,numost.str().c_str()
			) != 1) {
				return; // Cancel
			}
		}

#ifdef _WIN32
		std::string opa2( osapi::cp932_from_utf8( opa ) );
		std::string npa2( osapi::cp932_from_utf8( npa ) );
		if (opa2.empty() || npa2.empty()) {
			fl_alert("Error:rename \"%s\" \"%s\""
				,opa.c_str() ,npa.c_str() );
			return;
		}
		std::rename( opa2.c_str() ,npa2.c_str() );
#else
		std::rename( opa.c_str() ,npa.c_str() );
#endif
	}

	/* renumber成功したら、新しいStart,End,Numberに表示変更 */
	this->cb_set_number();
	this->cb_check_existing_saved_file();
}
Exemplo n.º 9
0
/* rename/renumber処理実行 */
void cb_trace_files::cb_rename(void)
{
	/* Openファイルのフルパスを得る */
	const std::string filepath = this->get_open_path( 1 );
	if (filepath.empty()) {
		fl_alert( "Not set Open Folder or File name" );
		return;
	}

	/* 連番ファイルの存在チェックして必要な情報に変える */
	std::string dpath , head , num , ext;
	int number=-1;
	std::vector<int> nums;
	ids::path::level_from_files(
		filepath ,dpath ,head ,num ,number ,ext ,nums
	);
	if (head.empty() || nums.size() <= 0) {
		fl_alert( "Not exist files" );
		return;
	}
	std::ostringstream numost;
	for (auto nu : nums) {
		numost << nu;
		numost << " ";
	}

	/* ユーザーから新しい名前を得る */
	const char* new_head_ptr = fl_input(
		"Enter New Level Name" ,head.c_str()
	);
	if (new_head_ptr == nullptr || head == new_head_ptr ) {
		return; /* Cancel or 同じ名前なら何もしない */
	}
	const std::string new_head(new_head_ptr);

	/* ファイル毎名前を変更する */
	for (size_t ii=0; ii<nums.size() ; ++ii) {
		std::string opa( this->get_open_path( nums.at(ii) ) );
		std::string npa( this->get_open_path_from_head_and_number_(
			new_head.c_str() ,nums.at(ii)
		));
		/* 最初にこれでいいかユーザーに確認する */
		if (ii==0) {
			if (fl_ask(
 "Rename\nFrom\n %s\nTo\n %s\nNumber List\n %s\nOK?"
				,opa.c_str()
				,npa.c_str()
				,numost.str().c_str()
			) != 1) {
				return; // Cancel
			}
		}

#ifdef _WIN32
		std::string opa2( osapi::cp932_from_utf8( opa ) );
		std::string npa2( osapi::cp932_from_utf8( npa ) );
		if (opa2.empty() || npa2.empty()) {
			fl_alert("Error:rename \"%s\" \"%s\""
				,opa.c_str() ,npa.c_str() );
			return;
		}
		std::rename( opa2.c_str() ,npa2.c_str() );
#else
		std::rename( opa.c_str() ,npa.c_str() );
#endif
	}

	/* rename成功したら、新しい名前に表示変更 */
	cl_gts_gui.strinp_trace_open_file_head->value( new_head.c_str() );
}
Exemplo n.º 10
0
int cb_trace_files::cb_start( const bool interactive_sw )
{
	if ( !cl_gts_master.cl_number.is_trace() ) {
		fl_alert("Set Number for Trace");
		return OK;
	}

	/* チェック:開くファイルのLevel名がない */
	{
	std::string name(cl_gts_gui.strinp_trace_open_file_head->value());
	if ( name.empty() ) {
		fl_alert("Need Trace Open Name!");
		return NG;
	}
	}

	/* チェック:保存ファイルのLevel名がない */
	{
	std::string name(cl_gts_gui.strinp_trace_save_file_head->value());
	if ( name.empty() ) {
		fl_alert("Need Trace Save Name!");
		return NG;
	}
	}

	/* チェック:開くファイル名がない */
	if (this->get_open_path(0).empty()) {
		fl_alert("Check Open Folder and File name!");
		return NG;
	}

	/* チェック:保存ファイル名がない */
	if (this->get_save_path(0).empty()) {
		fl_alert("Check Save Folder and File name!");
		return NG;
	}

	/* 順送り(start <= end)の初期位置 */
	cb_number &cl_num = cl_gts_master.cl_number;
	int list_num = cl_num.next_selected_list_num(1);

	/* チェック:番号選択がない */
	if (list_num < 1) {
		fl_alert("Select Number!");
		return NG;
	}

	/* 順送り(start <= end)の初期番号 */
	int file_num = cl_num.file_num_from_list_num(list_num);

	/* 実行確認 */
	if (interactive_sw) {
	 const bool tsw =
	  cl_gts_gui.chkbtn_trace_filter_trace_sw->value() != 0;
	 const bool esw =
	  cl_gts_gui.chkbtn_trace_filter_erase_dot_noise_sw->value() != 0;
	 if (fl_ask(
		"%s%s\n%s\n-->\n%s\n..."
		,tsw ?"Trace" :"Not trace"
		,esw ?" and Erase Dot Noise" :""
		,this->get_open_path(file_num).c_str()
		,this->get_save_path(file_num).c_str()
	 ) != 1) {
		return OK; // Cancel
	 }
	}

	while (1 <= list_num) {
		/* カレントの読み込みと処理と保存をして */
		if (OK != this->read_and_save_crnt_( file_num ,list_num )) {
			pri_funct_err_bttvr(
		 "Error : this->read_and_save_crnt_() returns NG" );
			return NG;
		}
		/* 次を得る */
		list_num = cl_num.next_selected_list_num( list_num + 1 );
		file_num = cl_num.file_num_from_list_num( list_num );

		Fl::check();
		const int ekey = Fl::event_key();

		/* FL_Escapeと'q'と't'は効かない */
		//if (FL_Escape == ekey) {
		//if ('q' == ekey) {
		//if ('t' == ekey) { /* Tで開始し、tで終る */

		if ('e' == ekey) {
			break;
		}
	}
	return OK;
}
Exemplo n.º 11
0
void load_tiles(Fl_Widget*,void*o){
	//if o=0 load if o=1 append if o=2 load at
	if(!currentProject->containsData(pjHaveTiles)){
		currentProject->haveMessage(pjHaveTiles);
		return;
	}
	size_t file_size;
	unsigned mode=(uintptr_t)o;
	char * returned=(char*)fl_input("What row should these tiles use?\nEnter 0 to 3 to selected a row or -1 to -4 to auto determine based on tilemap\nWhen specifing a negative number to figure out what the default will be use this formula abs(row)-1","-1");
	if (unlikely(!returned))
		return;
	if (unlikely(!verify_str_number_only(returned)))
		return;
	int row=atoi(returned);
	if (unlikely((row > 3) || (row < -4))){
		fl_alert("You entered %d which is out of range it must be in range of -4 to 3",row);
		return;
	}
	uint8_t defaultRow=row >= 0 ? row:abs(row)-1;
	int compression=compressionAsk();
	bool alphaZero=fl_ask("Set color #0 to alpha 0 instead of 255")?true:false;
	void*output;
	filereader f=filereader("Load tiles");
	if(f.amt==0)
		return;
	unsigned idx=f.selDat();
	file_size = f.lens[idx];
	unsigned truecolor_multiplier;
	truecolor_multiplier=256/currentProject->tileC->tileSize;
	if(compression)
		output=decodeTypeRam((uint8_t*)f.dat[idx],f.lens[idx],file_size,compression);
	else{
		if (file_size%currentProject->tileC->tileSize){
			fl_alert("Error: This is not a valid tile file each tile is %d bytes and this file is not a multiple of %d so it is not a valid tile file",currentProject->tileC->tileSize,currentProject->tileC->tileSize);
			return;
		}
	}
	uint32_t offset_tiles;
	uint32_t offset_tiles_bytes;
	if(mode==2){
		const char * str=fl_input("Counting from zero which tile should this start at?");
		if(!str){
			return;
		}
		if(!verify_str_number_only((char*)str)){
			return;
		}
		int off=atoi(str);
		if(off>=0){
			offset_tiles=off;
			offset_tiles_bytes=offset_tiles*currentProject->tileC->tileSize;
		}else{
			fl_alert("You must enter a number greater than or equal to zero");
			return;
		}
	}else if(mode==1){
		offset_tiles=currentProject->tileC->amt;
		offset_tiles_bytes=offset_tiles*currentProject->tileC->tileSize;
	}else{
		offset_tiles=0;
		offset_tiles_bytes=0;
	}
	if(mode==2){
		if(offset_tiles+(file_size/currentProject->tileC->tileSize)>=currentProject->tileC->amt)
			currentProject->tileC->tDat.resize(offset_tiles_bytes+file_size);
	}else
		currentProject->tileC->tDat.resize(offset_tiles_bytes+file_size);
	if(compression){
		memcpy(currentProject->tileC->tDat.data()+offset_tiles_bytes,output,file_size);
		free(output);
	}else
		memcpy(currentProject->tileC->tDat.data()+offset_tiles_bytes,f.dat[idx],file_size);
	if(currentProject->getTileType()!=PLANAR_TILE)
		currentProject->tileC->toPlanar(currentProject->getTileType(),offset_tiles,offset_tiles+(file_size/currentProject->tileC->tileSize));
	if(mode==2){
		if(offset_tiles+(file_size/currentProject->tileC->tileSize)>=currentProject->tileC->amt)
			currentProject->tileC->truetDat.resize((file_size*truecolor_multiplier)+(offset_tiles_bytes*truecolor_multiplier));
	}else
		currentProject->tileC->truetDat.resize((file_size*truecolor_multiplier)+(offset_tiles_bytes*truecolor_multiplier));
	for(uint32_t c=offset_tiles;c<(file_size/currentProject->tileC->tileSize)+offset_tiles;c++) {
		if(row < 0){
			uint32_t x,y;
			uint8_t foundRow=defaultRow;
			for(y=0;y<currentProject->tms->maps[currentProject->curPlane].mapSizeHA;++y){
				for(x=0;x<currentProject->tms->maps[currentProject->curPlane].mapSizeW;++x){
					if(currentProject->tms->maps[currentProject->curPlane].get_tile(x,y) == c) {
						foundRow=currentProject->tms->maps[currentProject->curPlane].getPalRow(x,y);
						goto doTile;
					}
				}
			}
doTile:
			currentProject->tileC->tileToTrueCol(&currentProject->tileC->tDat[(c*currentProject->tileC->tileSize)],&currentProject->tileC->truetDat[(c*256)],foundRow,true,alphaZero);
		}else
			currentProject->tileC->tileToTrueCol(&currentProject->tileC->tDat[(c*currentProject->tileC->tileSize)],&currentProject->tileC->truetDat[(c*256)],defaultRow,true,alphaZero);
	}
	if(mode==2){
		if(offset_tiles+(file_size/currentProject->tileC->tileSize)>=currentProject->tileC->amt){
			currentProject->tileC->amt=(file_size/currentProject->tileC->tileSize);
			currentProject->tileC->amt+=offset_tiles;
		}
	}else{
		currentProject->tileC->amt=(file_size/currentProject->tileC->tileSize);
		currentProject->tileC->amt+=offset_tiles;
	}
	updateTileSelectAmt();
	window->tile_select->value(0);
	window->tile_select_2->value(0);
	window->redraw();
}
Exemplo n.º 12
0
int fl_ask_lua(const char *msg)
{
  return fl_ask("%s", msg);
}