Exemple #1
0
int main() {
	srand(0); //seed generator with 0 for debugging
	dungeon *game = generate_dungeon(10, 20);

	tutorial(game);

	for(;;) {
		set_stage(game);
		get_desc(game);

		switch(input("", I_CHAR)) {
			case 'q': goto END_GAME;
			case 'n': move(game, D_NORTH); break;
			case 's': move(game, D_SOUTH); break;
			case 'e': move(game, D_EAST); break;
			case 'w': move(game, D_WEST); break;
			case 'i': action(game, A_INVENTORY); break;
			case 'd': action(game, A_DROP); break;
			case 'l': action(game, A_LOOT); break;
			case 'p': action(game, A_PUTON); break;
			case 'a': action(game, A_ARM); break;
			case 'c': action(game, A_CONSUME); break;
			case 'f': fight(game); break;
			case 'h': help(); break;
			case 'r': reflect(&(game->player)); break;
			case 'z': dump_dungeon(game); break;
			default: printf("Invalid Command!\n");
		}
	}
	END_GAME:
	return 0;
}
Exemple #2
0
logincheck()
{
    if ( thisAccount.special[ hour() ] )  /* Is is free time?     */
    {
        specialTime = TRUE;
    } else {
        specialTime = FALSE;
    }

    /* Local and bad calls get no accounting.   */
    if (!gotCarrier() || (whichIO == CONSOLE)) return(TRUE);

    if (  !thisAccount.days[ dayofweek() ]
    ||    !thisAccount.hours[ hour() ]
    ||     logBuf.credits <= 0 )
    {
        tutorial("nologin.blb");

        loggedIn = FALSE;

        terminate(TRUE, FALSE);

        return (FALSE);
    }

    if ( thisAccount.special[ hour() ] )  /* Is is free time?     */
    {
        specialTime = TRUE;
    }

    return (TRUE);
}
Exemple #3
0
void Troll::intro() {
    // sierra on-line presents
    _vm->clearScreen(0x2F);
    _vm->drawStr(9, 10, kColorDefault, IDS_TRO_INTRO_0);
    _vm->drawStr(14, 15, kColorDefault, IDS_TRO_INTRO_1);
    _vm->_gfx->doUpdate();
    _vm->_system->updateScreen();
    _vm->_system->delayMillis(3200);

    CursorMan.showMouse(true);

    // Draw logo
    _vm->setDefaultTextColor(0x0f);
    drawPic(45, false, true);
    _vm->_gfx->doUpdate();

    // wait for keypress and alternate message
    waitAnyKeyIntro();

    // have you played this game before?
    _vm->drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_4);
    _vm->drawStr(23, 6, kColorDefault, IDS_TRO_INTRO_5);
    _vm->_gfx->doUpdate();

    if (!_vm->getSelection(kSelYesNo))
        tutorial();

    credits();
}
Exemple #4
0
static void doTutorial()
{
	if (game.previousStatus == IN_TITLE)
	{
		tutorial();
	}

	else
	{
		game.menu = initYesNoMenu(_("Play the tutorial?"), &tutorial, &showMainMenu);

		game.drawMenu = &drawYesNoMenu;
	}
}
void completeReset(){ // Reset the whole game
    soundreset();
    g_eGameState = SPLASH;
    player.bomb = 1;
    fight = NORMAL;
    level = TUTORIALROOM;
    tutorial();
    Bhealth = 50;
    healthDMG = 0;
    ammoUsed = 0;
    bombUsed = 0;
    t_monsterDied = 0;
    t_monster1Died = 0;
	t_wProjectile = 0;
    uCooldown = 0;
    elapsedTime = 0;
    cobwebToken = 0;
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: eventChanged((*reinterpret_cast< AGSEventType(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 1: newFile(); break;
        case 2: openFile(); break;
        case 3: closeFile(); break;
        case 4: exportFile(); break;
        case 5: importToDatabase(); break;
        case 6: loadFile((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 7: openRecentFile(); break;
        case 8: showOptions(); break;
        case 9: updateTime(); break;
        case 10: lookupAGS_ID(); break;
        case 11: lookupPCC_ID(); break;
        case 12: lookupPCC_ID((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 13: setEventTypeID((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 14: setEvent((*reinterpret_cast< AGSEventType(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 15: setLogoutTime(); break;
        case 16: setLogoutTime((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 17: setTShirtCalc((*reinterpret_cast< double(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 18: setTimer((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 19: setTimer((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 20: boo(); break;
        case 21: showError((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 22: login(); break;
        case 23: logout(); break;
        case 24: about(); break;
        case 25: tutorial(); break;
        case 26: reportABug(); break;
        case 27: testConnection(); break;
        case 28: { QString _r = generateHeader();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 29: rewriteHeader(); break;
        default: ;
        }
        _id -= 30;
    }
    return _id;
}
STATE::STATE Cmenu::run(Cvao &vanilla, CshaderProgram &vanillaProgram, Cloader &loader, Copengl &opengl) {
    //This flag lets us set if we should restart the menu music next time the menu is entered
    //To start with we don't play menu music as the loading screen will have already started it and
    //we don't want to restart it.
    static bool shouldStartMenuMusic = false;
    if (shouldStartMenuMusic == true) {
        Csound::play_music(loader.get_menu_music());
    }
    //Should always be set to restart by default.
    shouldStartMenuMusic = true;

    if (init(vanilla, vanillaProgram, loader, opengl) == false) {
        return STATE::ENCOUNTERED_ERROR;
    }

    Cbutton startGame(MENU::START_GAME::X, MENU::START_GAME::Y, MENU::START_GAME::W, MENU::START_GAME::H);
    Cbutton tutorial(MENU::TUTORIAL::X, MENU::TUTORIAL::Y, MENU::TUTORIAL::W, MENU::TUTORIAL::H);
    Cbutton quitGame(MENU::QUIT_GAME::X, MENU::QUIT_GAME::Y, MENU::QUIT_GAME::W, MENU::QUIT_GAME::H);

    while (true) {
        SDL_Event event;
        SDL_WaitEvent(&event);

        if (event.type == SDL_MOUSEBUTTONDOWN) {
            float x = opengl.convert_to_opengl_from_window_x(event.button.x);
            float y = opengl.convert_to_opengl_from_window_y(event.button.y);
            if (startGame.isClicked(x, y) == true) {
                return STATE::GAMEPLAY;
            } else if (tutorial.isClicked(x, y) == true) {
                //We're going to the tutorial but will be back soon.
                //The current music should just keep going (not restart when they return to the menu).
                shouldStartMenuMusic = false;
                return STATE::TUTORIAL;
            } else if (quitGame.isClicked(x, y) == true) {
                return STATE::END_GAME;
            }
        } else if (event.type == SDL_QUIT || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
            return STATE::END_GAME;
        }
    }
}
Exemple #8
0
/* -------------------------------------------------------------------- */
void loginNew(char *initials, char *password)
{
    int i; 
    ulong newpointer;
    
    if (getYesNo(cfg.l_verified ? " No record: Enter as new user" 
                                : " No record: Request access", 1))
    {
        if (!CARRIER) return;
        
        if (cfg.l_closedsys && (!sysopNew && !(onConsole && !debug)))
        {
            tutorial("closesys.blb");
            drop_dtr();
            return;
        }
        
        tutorial("userinfo.blb");
        
        if (cfg.l_create || sysopNew || (onConsole && !debug))
        {
            logBuf.VERIFIED = (onConsole && !debug) ? FALSE : !cfg.l_verified;
            newUser(initials, password);
            if (!loggedIn)
                return;
            newaccount();
            update25();
        }

        if (cfg.l_questionare && (!(onConsole && !debug)))
        {
            newUserFile();
        }

        if (cfg.l_application && (!(onConsole && !debug)))
        {
            if (changedir(cfg.aplpath) == ERROR)
            {
                mPrintf("  -- Can't find application directory.\n\n");
                changedir(cfg.homepath);
                return;
            }
            apsystem(cfg.newuserapp);
            changedir(cfg.homepath);
        }

        if (cfg.l_sysop_msg && (!(onConsole && !debug)))
        {
            tutorial("newmsg.blb");
            
            i = loggedIn;       /* force to sysop */
            loggedIn = FALSE; 
            mailFlag  = TRUE; 
            oldFlag   = FALSE;
            limitFlag = FALSE;
            linkMess  = FALSE;
            makeMessage();
            loggedIn = (uchar)i;
        }
        
        if (logBuf.VERIFIED && !sysopNew && loggedIn)
        {
            verbose = FALSE;
            terminate(TRUE);
            mPrintf("\n Thank you, Good Bye.\n");
            Hangup();
        }
    }



/**********************************************************************/
/* Icky Hack designed to make #oldcount functional                    */
/* this was moved here because for some reason making messages        */
/* was causing the pointers to get screwed up                         */
/**********************************************************************/

    if (cfg.oldcount)
    {
        newpointer = (cfg.newest - cfg.oldcount);
        if (newpointer < cfg.oldest)  newpointer = cfg.oldest;

        /* logBuf.lbvisit[0] = newpointer; */ /* pushed down later by setlbvisit() */

        for (i = 0; i < MAXROOMS;  i++)
        {
            logBuf.newpointer[i] = newpointer;

            /* logBuf.lbroom[i].lvisit = 0; */ /* becomes==1 later by setlbvisit() */
        }
    }

/**********************************************************************/
/* ^^^ Disgusting? Wasn't it?  ^^^ Hope it works!                     */
/**********************************************************************/
    
    sysopNew = FALSE;
    
    return;
}
Exemple #9
0
/* -------------------------------------------------------------------- */
void newUser(char *initials, char *password)
{
    label fullnm;
    char InitPw[80];
    char Initials[80];
    char passWord[80];
    char *semicolon;
    int  lines;
    
    int abort, good = 0;
    char  firstime = 1;

    if (!CARRIER)  return;

    unlisted = FALSE;  /* default to [Y] for list in userlog for new users */
    roomtell = TRUE;   /* default to [Y] for display of room descriptions  */

    /* this only initializes log.buf, does not write it out */
    if (newlog() == ERROR) return;

    logBuf.linesScreen = cfg.linesScreen;
    /* askTerm(); */
    configure(TRUE);      /* make sure new users configure reasonably     */
    lines = logBuf.linesScreen;
    
    tutorial("password.blb");
    
    do
    {
        do
        {
            /* getNormStr("full name", fullnm, NAMESIZE, ECHO); */
            enterName(cfg.enter_name, fullnm, NULL);
            
            if ( (personexists(fullnm) != ERROR )
            ||   (strcmpi(fullnm, "Sysop") == SAMESTRING)
            ||   (strcmpi(fullnm, "Aide") == SAMESTRING)
            ||   !strlen(fullnm) )
            {
                mPrintf("We already have a %s\n", fullnm);
                good = FALSE;
            }        
            else (good = TRUE);
        }
        while(!good && CARRIER);

        if (!CARRIER)  return;

        if (firstime)
        {
            strcpy(Initials, initials);
        }
        else
        {
            getNormStr("your initials", InitPw, 40, NO_ECHO);
            dospCR();

            semicolon = strchr(InitPw, ';');

            if( semicolon )
            {
               normalizepw(InitPw, Initials, passWord);
            }
            else
            {
                strcpy(Initials, InitPw);
            }

            /* dont allow anything over 19 characters */
            Initials[19] = '\0';
        }

        do
        {
            if (firstime)
            {
                strcpy(passWord, password);
            }
            else if (!semicolon)
            {
                getNormStr("password",  passWord, NAMESIZE, NO_ECHO);
                dospCR();
            }
            
            firstime  = FALSE;  /* keeps from going in infinite loop */
            semicolon = FALSE;

            if ( pwexists(passWord) != ERROR || strlen(passWord) < 2)
            {
                good = FALSE;
                mPrintf("\n Poor password\n ");
            }
            else good = TRUE;
        }
        while( !good  && CARRIER );

        displaypw(fullnm, Initials, passWord);

        abort = getYesNo("OK",2);

        if (abort == 2) return;  /* check for Abort at (Y/N/A)[A]: */
    }
    while ( (!abort) && CARRIER);

    if (CARRIER)
    {
        /* Moved from newlog() */
        strcpy(logBuf.lbname, fullnm);
        strcpy(logBuf.lbin, Initials);
        strcpy(logBuf.lbpw, passWord);

        /* This stuff moved from newlog()
        time(&logBuf.calltime);

        setsysconfig();

        /*
         * trap it 
         */
        sprintf( msgBuf->mbtext, "New user %s", logBuf.lbname);
        if (onConsole)
            strcat(msgBuf->mbtext, " (Console)");
        trap(msgBuf->mbtext, T_LOGIN);

        loggedIn = TRUE;
        slideLTab(thisSlot);
        storeLog();

        /* End of stuff moved from newlog() */
    }

    logBuf.linesScreen = (uchar)lines;
}
// 
// メインプログラム
// 
int main() {
	// アプリウインドウの準備
	AppEnv app_env(Window::WIDTH, Window::HEIGHT);

	// ハイスコア
	int hi_score = 0;
	{
		std::ifstream fstr("score.txt");
		if (fstr){
			fstr >> hi_score;
		}
	}
	// 結果画面からタイトル画面に戻るループ
	while (1){
		// 背景を動かす変数
		float scroll_back = 0;
		// 飛距離
		int jump_distance = 0;

		// タイトル画面
		{
			// タイトル画像
			Texture title_image("res/title_back.png");
			Texture title_rogo("res/title.png");
			Texture GAMESTART("res/GAME START.png");

			// 「Run and Jump」演出用変数を用意
			float title_angle = 0.0;
			int blink = 0;
			// メインループ
			while (1) {
				// ウィンドウが閉じられたらアプリを終了
				if (!app_env.isOpen()) return 0;

				// 描画準備
				app_env.setupDraw();

				// 入力による操作(break本編へ,returnアプリ終了)
				if (app_env.isPushButton(Mouse::RIGHT)) break;
				if (app_env.isPushButton(Mouse::LEFT))  break;
				if (app_env.isPushKey(GLFW_KEY_ENTER))  break;
				if (app_env.isPushKey(GLFW_KEY_ESCAPE)) return 0;

				// タイトル画像
				drawTextureBox(0 - 2048 / 2, 0 - 1024 / 2, 2048, 1024,
					0, 0, 2048, 1024,
					title_image,
					Color(1, 1, 1));

				// タイトルロゴの色にサイン,コサインを利用
				title_angle += 0.05;
				float title_sin = std::abs(std::sin(title_angle));
				float title_cos = std::abs(std::cos(title_angle));

				// タイトルロゴを表示
				drawTextureBox(0 - 1024 / 2, 512 / 2, 565, 80,
					0, 512, 565, 80,
					title_rogo,
					Color(0, title_sin, title_cos),
					0,
					Vec2f(2, 2),
					Vec2f(0, 0));

				// 「GAME START」を表示
				blink += 1;
				int value = (blink / 30) % 2;

				if (value){
					drawTextureBox(0 - 360, 0 - 480, 512, 256,
						0, 0, 512, 256,
						GAMESTART,
						Color(1, 0, 0),
						0,
						Vec2f(1.8, 1.8),
						Vec2f(0, 0));
				}
				// 画面を更新
				app_env.update();
			}
			// 入力のフラッシュ
			app_env.flushInput();
		}
		// 操作説明画面
		{
		// 操作説明画像
		Texture tutorial("res/tuto.png");
		Texture back("res/field.png");

		// メインループ
		while (1) {
			// ウィンドウが閉じられたらアプリを終了
			if (!app_env.isOpen()) return 0;

			// 描画準備
			app_env.setupDraw();

			// 入力による操作(break本編へ,returnアプリ終了)
			if (app_env.isPushButton(Mouse::RIGHT)) break;
			if (app_env.isPushButton(Mouse::LEFT))  break;
			if (app_env.isPushKey(GLFW_KEY_ENTER))  break;
			if (app_env.isPushKey(GLFW_KEY_ESCAPE)) return 0;

			// 操作説明画面
			drawTextureBox(0 - 2048 / 2, 0 - 1024 / 2, 2048, 1024,
				0, 0, 2048, 1024,
				back,
				Color(1, 1, 1));

			drawTextureBox(0 - 2048 / 2, 0 - 1024 / 2, 2048, 1024,
				0, 0, 2048, 1024,
				tutorial,
				Color(1, 1, 1));

			// 画面を更新
			app_env.update();

			// 入力のフラッシュ
			app_env.flushInput();
		}

		// 本編
		{
			// 本編の画像
			Texture back("res/field.png");
			Texture run("res/run.png");
			Texture jump("res/jump.png");
			Texture back2("res/field2.png");
			Texture back3("res/field3.png");
			Texture dispnumber("res/number.png");

			int blink = 0;
			// キャラの表示位置
			float x = 0 - 1024 / 1.5;
			float y = 0 - 380;
			// キャラの加速度
			float a = 0;
			// 重力加速度
			float g = -0.2;
			// キャラの速度
			float v = 0;
			// キャラのジャンプ回数
			int jump_count = 3;
			// キャラのジャンプスイッチ
			int jump_switch = 0;

			// メインループ
			while (1){
				// ウインドウが閉じられたら終了
				if (!app_env.isOpen()) return 0;
				if (app_env.isPushKey(GLFW_KEY_ESCAPE)) return 0;

				// 描画準備
				app_env.setupDraw();

				// キャラクターのモーション情報
				struct Texture {
					// 画像からの切り抜き情報
					float texture_x, texture_y;
					float texture_width, texture_height;
				};

				// キャラクターの情報を配列で用意
				Texture move_info[] = {
					{ 0 * 100, 0, 100, 150 },
					{ 1 * 100, 0, 100, 150 },
					{ 2 * 100, 0, 100, 150 },
					{ 3 * 100, 0, 100, 150 },
					{ 4 * 100, 0, 100, 150 },
					{ 5 * 100, 0, 100, 150 },
					{ 6 * 100, 0, 100, 150 },
				};

				// 数字の情報を配列で用意
				Texture number_info[] = {
					{ 0 * 50, 0, 29, 55 },
					{ 1 * 50, 0, 48, 54 },
					{ 2 * 50, 0, 44, 55 },
					{ 3 * 50, 0, 45, 54 },
					{ 4 * 50, 0, 47, 54 },
					{ 5 * 50, 0, 43, 55 },
					{ 6 * 50, 0, 43, 54 },
					{ 7 * 50, 0, 45, 55 },
					{ 8 * 50, 0, 43, 55 },
					{ 9 * 50, 0, 38, 57 },
				};

				// キャラクターの情報を配列から取り出す
				Texture move_chara1 = move_info[0];
				Texture move_chara2 = move_info[1];
				Texture move_chara3 = move_info[2];
				Texture move_chara4 = move_info[3];
				Texture move_chara5 = move_info[4];
				Texture move_chara6 = move_info[5];
				Texture move_chara7 = move_info[6];

				Texture disp_num1 = number_info[0];
				Texture disp_num2 = number_info[1];
				Texture disp_num3 = number_info[2];
				Texture disp_num4 = number_info[3];
				Texture disp_num5 = number_info[4];
				Texture disp_num6 = number_info[5];
				Texture disp_num7 = number_info[6];
				Texture disp_num8 = number_info[7];
				Texture disp_num9 = number_info[8];
				Texture disp_num0 = number_info[9];

				// ゲーム本編
				{
					
					// キャラクター処理
					{
						// 本編背景を連ねて表示に必要な変数
						int draw_back = 0;
						float num_x = -Window::WIDTH / 2 + 50;
						float num_y = -Window::HEIGHT / 2 + 25;

						// 本編画像を表示					
						draw_back += 2000;

						if (app_env.isPressKey(GLFW_KEY_RIGHT)){
							scroll_back += 20;
						}

						drawTextureBox(0 - 2048 / 2 - scroll_back, 0 - 1024 / 2,
							2048, 1024,
							0, 0,
							2048, 1024,
							back,
							Color(1, 1, 1));

						drawTextureBox(0 - 2048 / 2 - scroll_back + 2000, 0 - 1024 / 2,
							2048, 1024,
							0, 0,
							2048, 1024,
							back,
							Color(1, 1, 1));

						drawTextureBox(0 - 2048 / 2 - scroll_back + 4000, 0 - 1024 / 2,
							2048, 1024,
							0, 0,
							2048, 1024,
							back2,
							Color(1, 1, 1));

						drawTextureBox(0 - 2048 / 2 - scroll_back + 6000, 0 - 1024 / 2,
							2048, 1024,
							0, 0,
							2048, 1024,
							back3,
							Color(1, 1, 1));

						drawTextureBox(0 - 2048 / 2 - scroll_back + 8000, 0 - 1024 / 2,
							2048, 1024,
							0, 0,
							2048, 1024,
							back3,
							Color(1, 1, 1));

						drawTextureBox(0 - 2048 / 2 - scroll_back + 10000, 0 - 1024 / 2,
							2048, 1024,
							0, 0,
							2048, 1024,
							back3,
							Color(1, 1, 1));

						// キャラをジャンプさせる
						if (app_env.isPushKey(GLFW_KEY_SPACE) && jump_count > 0){
							a = 10 + g;
							jump_count--;
							jump_switch = 1;
						}
						else{
							a = g;
						}
						v = v + a;
						y = y + ((1 / 2) * a) + v;

						if (y < (0 - 380)) {
							v = 0;
							y = 0 - 380;
							// キャラが飛んでから地面に足をついたら結果画面へ
							if (jump_switch == 1 && y <= 0 - 380){
								break;
							}
						}

						// キャラが画面上端を超えたら止める
						if (y >= 512 - 200){
							y = 512 - 200;
							v = 0;
						}

						// キャラを表示
						if (app_env.isPressKey(GLFW_KEY_RIGHT)){
							blink += 1;
						}
						int value = (blink / 3) % 7;

						drawTextureBox(x, y, move_info[value].texture_width, move_info[value].texture_height,
							move_info[value].texture_x, move_info[value].texture_y,
							move_info[value].texture_width, move_info[value].texture_height,
							run,
							Color(0, 0, 0),
							0,
							Vec2f(1.5, 1.5),
							Vec2f(0, 0));
						

						// 飛距離を表示する
						if (scroll_back >= 3250 - x && jump_count >= 0){
							jump_distance = (scroll_back - 4100) / 20;
						}
						// 線を越えても飛んでなかったらファウル
						if (scroll_back >= 3300 - x && jump_count == 3){
							jump_distance = 0;
							break;
						}

						// 100の位
						if (jump_distance >= 100){
							int hundred_distance = jump_distance / 100;
							if (hundred_distance != 0){
								drawTextureBox(num_x, num_y, number_info[hundred_distance - 1].texture_width, number_info[hundred_distance - 1].texture_height,
									number_info[hundred_distance - 1].texture_x, number_info[hundred_distance - 1].texture_y,
									number_info[hundred_distance - 1].texture_width, number_info[hundred_distance - 1].texture_height,
									dispnumber,
									Color(1, 1, 1),
									0,
									Vec2f(3, 3),
									Vec2f(0, 0));
							}
							if (hundred_distance == 0){
								drawTextureBox(num_x, num_y, number_info[9].texture_width, number_info[9].texture_height,
									number_info[9].texture_x, number_info[9].texture_y,
									number_info[9].texture_width, number_info[9].texture_height,
									dispnumber,
									Color(1, 1, 1),
									0,
									Vec2f(3, 3),
									Vec2f(0, 0));
							}
						}
						// 10の位
						if (jump_distance >= 10){
							int ten_distance = jump_distance % 100 / 10;
							if (ten_distance != 0){
								drawTextureBox(num_x + 120, num_y, number_info[ten_distance - 1].texture_width, number_info[ten_distance - 1].texture_height,
									number_info[ten_distance - 1].texture_x, number_info[ten_distance - 1].texture_y,
									number_info[ten_distance - 1].texture_width, number_info[ten_distance - 1].texture_height,
									dispnumber,
									Color(1, 1, 1),
									0,
									Vec2f(3, 3),
									Vec2f(0, 0));
							}
							if (ten_distance == 0){
								drawTextureBox(num_x + 120 , num_y, number_info[9].texture_width, number_info[9].texture_height,
									number_info[9].texture_x, number_info[9].texture_y,
									number_info[9].texture_width, number_info[9].texture_height,
									dispnumber,
									Color(1, 1, 1),
									0,
									Vec2f(3, 3),
									Vec2f(0, 0));
							}
						}
						// 1の位
						if (jump_distance >= 1){
							int one_distance = jump_distance % 10;
							if (one_distance != 0){
								drawTextureBox(num_x + 240, num_y, number_info[one_distance - 1].texture_width, number_info[one_distance - 1].texture_height,
									number_info[one_distance - 1].texture_x, number_info[one_distance - 1].texture_y,
									number_info[one_distance - 1].texture_width, number_info[one_distance - 1].texture_height,
									dispnumber,
									Color(1, 1, 1),
									0,
									Vec2f(3, 3),
									Vec2f(0, 0));
							}
							if (one_distance == 0){
								drawTextureBox(num_x + 240, num_y, number_info[9].texture_width, number_info[9].texture_height,
									number_info[9].texture_x, number_info[9].texture_y,
									number_info[9].texture_width, number_info[9].texture_height,
									dispnumber,
									Color(1, 1, 1),
									0,
									Vec2f(3, 3),
									Vec2f(0, 0));
							}
						}
					}
					// ハイスコア更新チェック
					if (jump_distance > hi_score){
						std::ofstream fstr("score.txt");
						if (fstr){
							fstr << jump_distance << std::endl;
							hi_score = jump_distance;
						}
					}

					// 画面を更新
					app_env.update();
				}
				// 入力のフラッシュ
				app_env.flushInput();
			}

			// 結果画面
			{
				Texture result("res/result.png");
				Texture back("res/field.png");
				Texture dispnumber("res/number.png");
				Texture Return("res/Return to Title");

				// メインループ
				while (1) {
					// ウィンドウが閉じられたらアプリを終了
					if (!app_env.isOpen()) return 0;

					float num_x = 0 - 25 / 2;
					float num_y_now = 0 - 30 / 2;
					float num_y_hi = 0 - 30 / 2 - 270;

					// 描画準備
					app_env.setupDraw();

					// 入力による操作(break本編へ,returnアプリ終了)
					if (app_env.isPushButton(Mouse::RIGHT)) break;
					if (app_env.isPushButton(Mouse::LEFT))  break;
					if (app_env.isPushKey(GLFW_KEY_ENTER))  break;
					if (app_env.isPushKey(GLFW_KEY_ESCAPE)) return 0;

					// 結果画面表示
					drawTextureBox(0 - 2048 / 2, 0 - 1024 / 2, 2048, 1024,
						0, 0, 2048, 1024,
						back,
						Color(1, 1, 1));

					drawTextureBox(0 - 2048 / 2, 0 - 1024 / 2, 2048, 1024,
						0, 0, 2048, 1024,
						result,
						Color(1, 1, 1));

					// 「Return to Title」を表示
					drawTextureBox(0 - 360, 0 - 480, 512, 256,
							0, 0, 512, 256,
							Return,
							Color(1, 0, 0),
							0,
							Vec2f(1.8, 1.8),
							Vec2f(0, 0));

					// 100の位
					if (jump_distance >= 100){
						int hundred_distance = jump_distance / 100;
						if (hundred_distance != 0){
							drawTextureBox(num_x, num_y_now, number_info[hundred_distance - 1].texture_width, number_info[hundred_distance - 1].texture_height,
								number_info[hundred_distance - 1].texture_x, number_info[hundred_distance - 1].texture_y,
								number_info[hundred_distance - 1].texture_width, number_info[hundred_distance - 1].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
						if (hundred_distance == 0){
							drawTextureBox(num_x, num_y_now, number_info[9].texture_width, number_info[9].texture_height,
								number_info[9].texture_x, number_info[9].texture_y,
								number_info[9].texture_width, number_info[9].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
					}
					// 10の位
					if (jump_distance >= 10){
						int ten_distance = jump_distance % 100 / 10;
						if (ten_distance != 0){
							drawTextureBox(num_x + 120, num_y_now, number_info[ten_distance - 1].texture_width, number_info[ten_distance - 1].texture_height,
								number_info[ten_distance - 1].texture_x, number_info[ten_distance - 1].texture_y,
								number_info[ten_distance - 1].texture_width, number_info[ten_distance - 1].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
						if (ten_distance == 0){
							drawTextureBox(num_x + 120, num_y_now, number_info[9].texture_width, number_info[9].texture_height,
								number_info[9].texture_x, number_info[9].texture_y,
								number_info[9].texture_width, number_info[9].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
					}
					// 1の位
					if (jump_distance >= 1){
						int one_distance = jump_distance % 10;
						if (one_distance != 0){
							drawTextureBox(num_x + 240, num_y_now, number_info[one_distance - 1].texture_width, number_info[one_distance - 1].texture_height,
								number_info[one_distance - 1].texture_x, number_info[one_distance - 1].texture_y,
								number_info[one_distance - 1].texture_width, number_info[one_distance - 1].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
						if (one_distance == 0){
							drawTextureBox(num_x + 240, num_y_now, number_info[9].texture_width, number_info[9].texture_height,
								number_info[9].texture_x, number_info[9].texture_y,
								number_info[9].texture_width, number_info[9].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
					}
					// ハイスコア
					// 100の位
					if (jump_distance >= 100){
						int hundred_distance = jump_distance / 100;
						if (hundred_distance != 0){
							drawTextureBox(num_x, num_y_hi, number_info[hundred_distance - 1].texture_width, number_info[hundred_distance - 1].texture_height,
								number_info[hundred_distance - 1].texture_x, number_info[hundred_distance - 1].texture_y,
								number_info[hundred_distance - 1].texture_width, number_info[hundred_distance - 1].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
						if (hundred_distance == 0){
							drawTextureBox(num_x, num_y_hi, number_info[9].texture_width, number_info[9].texture_height,
								number_info[9].texture_x, number_info[9].texture_y,
								number_info[9].texture_width, number_info[9].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
					}
					// 10の位
					if (jump_distance >= 10){
						int ten_distance = jump_distance % 100 / 10;
						if (ten_distance != 0){
							drawTextureBox(num_x + 120, num_y_hi, number_info[ten_distance - 1].texture_width, number_info[ten_distance - 1].texture_height,
								number_info[ten_distance - 1].texture_x, number_info[ten_distance - 1].texture_y,
								number_info[ten_distance - 1].texture_width, number_info[ten_distance - 1].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
						if (ten_distance == 0){
							drawTextureBox(num_x + 120, num_y_hi, number_info[9].texture_width, number_info[9].texture_height,
								number_info[9].texture_x, number_info[9].texture_y,
								number_info[9].texture_width, number_info[9].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
					}
					// 1の位
					if (jump_distance >= 1){
						int one_distance = jump_distance % 10;
						if (one_distance != 0){
							drawTextureBox(num_x + 240, num_y_hi, number_info[one_distance - 1].texture_width, number_info[one_distance - 1].texture_height,
								number_info[one_distance - 1].texture_x, number_info[one_distance - 1].texture_y,
								number_info[one_distance - 1].texture_width, number_info[one_distance - 1].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
						if (one_distance == 0){
							drawTextureBox(num_x + 240, num_y_hi, number_info[9].texture_width, number_info[9].texture_height,
								number_info[9].texture_x, number_info[9].texture_y,
								number_info[9].texture_width, number_info[9].texture_height,
								dispnumber,
								Color(1, 1, 1),
								0,
								Vec2f(3, 3),
								Vec2f(0, 0));
						}
					}

					// 画面を更新
					app_env.update();
				}
				// 入力のフラッシュ
				app_env.flushInput();
			}
		}
	}
		// アプリ終了
	}
}
Exemple #11
0
// on "init" you need to initialize your instance
bool GameScreen::init()
{
    points = 0;
    botoIsAlive = true;
	bonus = 0;
	multiplier = 1;
	numberOfBonuses = 1;
	pressedPause = false;
	scale = 1.0f;

    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    //add background
    auto background = Sprite::create(GAME_SCENE_BACKGROUND);
    background->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    this->addChild(background, 0);

	//boto sprite added
	botoSprite = new BotoSprite();
	botoSprite->draw(this, BOTO_ZORDER);

	//add ground
	ground = new Ground();
	ground->draw(this, GROUND_ZORDER);

	//covers movements updates
	this->scheduleUpdate();

    //pause button declaration
	auto menu_item = MenuItemImage::create(PAUSE_BUTTON,PAUSE_BUTTON_PRESSED, CC_CALLBACK_1(GameScreen::Pause, this));
	auto menu = Menu::create(menu_item, NULL);
	menu->setPosition(Point(0 + visibleSize.width / 1920 * 200 / 2, visibleSize.height - visibleSize.height / 1920 * 200 / 2));
	this->addChild(menu, BUTTONS_ZORDER);

	//Points label for points output

	pointsLabel = Label::createWithBMFont("fonts/west_england-64.fnt", "Points: 0",TextHAlignment::LEFT, visibleSize.width/7*2);
	pointsLabel->setHeight(visibleSize.height/20);
	pointsLabel->setScale(0.7);
	pointsLabel->setPosition(Point((visibleSize.width / 7 * 5) , (visibleSize.height * 19 / 20)));
	this->addChild(pointsLabel, BUTTONS_ZORDER);

	//single touch listener
	auto singleListener = EventListenerTouchOneByOne::create();
	singleListener->setSwallowTouches(true);
	singleListener->onTouchBegan = CC_CALLBACK_2(GameScreen::onTouchBegan, this);
	singleListener->onTouchEnded = CC_CALLBACK_2(GameScreen::onTouchEnded, this);
	_eventDispatcher->addEventListenerWithSceneGraphPriority(singleListener, this);

	//contact listener
	auto contactListener = EventListenerPhysicsContact::create();
	contactListener->onContactBegin = CC_CALLBACK_1(GameScreen::onContactBegin, this);
	_eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this);

	//sprites' textures initialization
	bonusSprite = Sprite::create(BONUS_SPEED);
	bonusSprite = Sprite::create(BONUS_SGRAVITY);
	bonusSprite = Sprite::create(BONUS_FGRAVITY);
	bonusSprite = Sprite::create(BONUS_SBOTO);
	bonusSprite = Sprite::create(BONUS_X2);
	tap1 = Sprite::create(TAP_PATH);

	newBlock = new Blocks();
	newBlock->init();
	coin = new Coins();
	pause = Sprite::create(PAUSE_BACKGROUND);
	pause = Sprite::create(GAMEOVER_BACKGROUND);
	musicIsOn = true;
	tutorial();
	return true;
}
Exemple #12
0
/* -------------------------------------------------------------------- */
void doLogin(char moreYet)
{
    int foundIt;
    char InitPw[NAMESIZE+NAMESIZE+2];
    char password[NAMESIZE+NAMESIZE+2];
    char initials[NAMESIZE+NAMESIZE+2];
    char *semicolon;

    Mflush();

    if (!CARRIER) return;

    if (login_user || login_pw) /* handle command line log-ins */
    {
        if (!modStat) 
            if (cfg.offhook)  offhook();

        /* login using initials and pw */
        if (login_pw)
        {
            normalizepw(cmd_login, initials, password);
            login_pw = FALSE;
        }
        else

        if (login_user)
        {
            normalizeString(cmd_login);
            if (findPerson(cmd_login, &logBuf) != ERROR)
            {
                strcpy(initials, logBuf.lbin);
                strcpy(password, logBuf.lbpw);
            }
            login_user = FALSE;
        }

    }
    else   /* ask user for initials and password */
    {


    if (moreYet == 2)
        moreYet = FALSE;
    else
    {
        /* dont print Login when hitting 'L' from console mode */
        if (!(!moreYet && !loggedIn && !modStat))
        {
            mPrintf("Login ");
        }
    }



    if (loggedIn)  
    {
        mPrintf("\n Already logged in!\n ");
        return;
    }

    if (!modStat) 
        if (cfg.offhook)  offhook();


  getNormStr((moreYet) ? "" : "your initials", InitPw, NAMESIZE+NAMESIZE+1, NO_ECHO);
    if (!CARRIER) return;

        dospCR();

        semicolon = strchr(InitPw, ';');

        if (!semicolon)
        {
            strcpy(initials, InitPw);
            getNormStr( "password",  password, NAMESIZE, NO_ECHO);
            dospCR();
        }     
        else  
        {
            normalizepw(InitPw, initials, password);
        }

        /* dont allow anything over 19 characters */
        initials[NAMESIZE] = '\0';
    }
    
    /* reset transmitted & received */
    transmitted = 0l;
    received    = 0l;

    /* reset read & entered */
    mread   = 0;
    entered = 0;

    foundIt = ((pwslot(initials, password)) != ERROR);

    if (foundIt && *password)
    {
        loggedIn    = TRUE;
        update25();

        /* trap it */
        if (!logBuf.lbflags.NODE) 
        {
            sprintf( msgBuf->mbtext, "Login %s", logBuf.lbname);
            if (onConsole)
                strcat(msgBuf->mbtext, " (Console)");

            trap(msgBuf->mbtext, T_LOGIN);
        }
        else
        {
            sprintf( msgBuf->mbtext, "NetLogin %s", logBuf.lbname);
            trap(msgBuf->mbtext, T_NETWORK);
        }
    }
    else
    {
        loginNew(initials, password);
    }

    if (!loggedIn)
        return;

    heldMessage = FALSE;

    setsysconfig();
    setgroupgen();
    setroomgen();
    setlbvisit();

    slideLTab(thisSlot);

    /* cant log in now. */
    if (cfg.accounting && !logBuf.lbflags.NOACCOUNT)
    {
        negotiate();
        logincrement();
        if (!logincheck()) 
        {
            Hangup();
            return;
        }
    }

    /* can't log in now. */
    if (logBuf.VERIFIED && !onConsole)
    {
        tutorial("verified.blb");
        Hangup();
        return;
    }

    if (logBuf.lbflags.NODE)
    {
#ifdef  TRASH       
        if (debug)
        {
            readnode();

            cPrintf("Node:  \"%s\" \"%s\"", node.ndname, node.ndregion);  doccr();
            cPrintf("Phone: \"%s\" %d", node.ndphone, node.nddialto);     doccr();
            cPrintf("Login: \"%s\" %d", node.ndlogin, node.ndwaitto);     doccr();
            cPrintf("Baud:  %d    Protocol: \"%s\"\n ", node.ndbaud, node.ndprotocol);
            cPrintf("Expire:%d    Waitout:  %d", node.ndexpire, node.ndwaitto); doccr();
            cPrintf("Network: %d  ZIP: %s UNZIP: %s", node.network, node.zip, node.unzip); doccr();
        }
#endif        
        
        time(&logtimestamp);
        return;
    }

    if (logBuf.PSYCHO)
    {
        backout = TRUE;
    }
    
    /* reverse engineering Minibin?!?! */
    if (logBuf.MINIBIN)
    {
        minibin();
    }
    
    changedir(cfg.helppath); 

    if ( filexists("bulletin.blb") )
    {
        tutorial("bulletin.blb");
    }
    
    gotodefaulthall();

    roomtalley();

    mf.mfLim = 0;   /* just to make sure. */
    mf.mfMai = 0;
    mf.mfPub = 0;
    mf.mfUser[0]=0;

    nochat(TRUE);       /* reset chats */
    
    /* verbose = FALSE; */
    verbose = logBuf.VERBOSE;

    /* hmmm... where to put this */
    if (roomBuf.rbflags.APLIC && roomBuf.rbflags.AUTOAPP )
        ExeAplic();

    showMessages(NEWoNLY, FALSE);

    verbose = FALSE;
    if (expert) listRooms(NEWRMS, FALSE);
    else        listRooms(OLDNEW, FALSE);

    outFlag = OUTOK;
    setio(whichIO, echo, outFlag);
    
    /* record login time, date */
    time(&logtimestamp);

    cfg.callno++;

    storeLog();
}
void TaskJuggler::setupActions()
{
    // "File" menu
    KStdAction::openNew(this, SLOT(fileNew()), actionCollection());
    new KAction(i18n("New &Include File" ), "file_temporary", KShortcut(),
                this, SLOT(fileNewInclude()),
                actionCollection(), "new_include");
    KStdAction::open(this, SLOT(fileOpen()), actionCollection());
    KStdAction::close(this, SLOT(fileClose()), actionCollection());
    KStdAction::print(this, SLOT(filePrint()), actionCollection());
    KStdAction::quit(kapp, SLOT(closeAllWindows()), actionCollection());

    // Setup "Open Recent" menu and load old recent files.
    m_recentAction = KStdAction::openRecent(this, SLOT(load(const KURL&)),
                                            actionCollection());


    // "Goto" menu
    new KAction(i18n("Tas&ks"), "tj_task_group", KShortcut(KKey("ALT+k")),
                m_view, SLOT(setFocusToTaskList()),
                actionCollection(), "tasks");
    new KAction(i18n("&Resources"), "tj_resource_group",
                KShortcut(KKey("ALT+r")),
                m_view, SLOT(setFocusToResourceList()),
                actionCollection(), "resources");
    new KAction(i18n("&Accounts"), "tj_account_group",
                KShortcut(KKey("ALT+a")),
                m_view, SLOT(setFocusToAccountList()),
                actionCollection(), "accounts");
    new KAction(i18n("Re&ports"), "tj_report_list", KShortcut(KKey("ALT+p")),
                m_view, SLOT(setFocusToReportList()),
                actionCollection(), "reports");
    new KAction(i18n("F&iles"), "tj_file_list", KShortcut(KKey("ALT+i")),
                m_view, SLOT(setFocusToFileList()),
                actionCollection(), "files");
    new KAction(i18n("E&ditor"), "tj_editor", KShortcut("ALT+d"),
                m_view, SLOT(setFocusToEditor()),
                actionCollection(), "editor");
    new KAction(i18n("Rep&ort"), "tj_report", KShortcut("ALT+o"),
                m_view, SLOT(setFocusToReport()),
                actionCollection(), "report");

    // "Tools" menu
    new KAction(i18n("&Schedule"), "tj_schedule", KShortcut(KKey("F9")),
                m_view, SLOT(schedule()),
                actionCollection(), "schedule");
    new KAction(i18n("Stop scheduling"), "stop", 0,
                m_view, SLOT(stop()),
                actionCollection(), "stop");
    new KAction(i18n("&Generate all Reports"), 0, 0,
                m_view, SLOT(generate()),
                actionCollection(), "generate");
    new KAction(i18n("Goto &previous Problem"), "tj_previous_problem",
                KShortcut(KKey("F10")),
                m_view, SLOT(previousProblem()),
                actionCollection(), "previous_problem");
    new KAction(i18n("Goto &next Problem"), "tj_next_problem",
                KShortcut(KKey("F11")),
                m_view, SLOT(nextProblem()),
                actionCollection(), "next_problem");

    new KAction(i18n("Zoom &In"), "viewmag+", KShortcut(KKey("F7")),
                m_view, SLOT(zoomIn()),
                actionCollection(), "zoom_in");
    new KAction(i18n("Zoom &Out"), "viewmag-", KShortcut(KKey("F8")),
                m_view, SLOT(zoomOut()),
                actionCollection(), "zoom_out");

    // "Help" menu
    new KAction(i18n("Tip of the day"), "idea", 0, this,
                SLOT(showTip()), actionCollection(), "tip");
    new KAction(i18n("Explain Keyword"), "tj_keyword_help",
                KShortcut(KKey("F2")),
                m_view, SLOT(keywordHelp()),
                actionCollection(), "keyword_help");
    new KAction(i18n("Tutorial"), "tj_tutorial", 0,
                m_view, SLOT(tutorial()),
                actionCollection(), "tutorial");

    setupGUI(ToolBar | Keys | StatusBar | Save | Create);
}
Exemple #14
0
int main(int argc, char *argv[])
{
	unsigned int frameLimit;
	int go, i, mapID, loadSlot, recordingID, replayingID;
	int joystick, showCredits, languageID;

	go = TRUE;

	loadSlot = -1;

	game.fps = 1000 / 60;

	languageID = mapID = recordingID = replayingID = -1;

	joystick = 0;

	showCredits = FALSE;

	/* Load the resources */

	for (i=1;i<argc;i++)
	{
		if (strcmpignorecase("-record", argv[i]) == 0)
		{
			if (i + 1 >= argc)
			{
				printf("You must specify a file to record to\n");
				printf("Type %s -h for help\n", argv[0]);

				exit(1);
			}

			if (recordingID == -1)
			{
				recordingID = i + 1;
			}

			i++;
		}

		else if (strcmpignorecase("-playback", argv[i]) == 0)
		{
			if (i + 1 >= argc)
			{
				printf("You must specify a file to playback from\n");
				printf("Type %s -h for help\n", argv[0]);

				exit(1);
			}

			if (replayingID == -1)
			{
				replayingID = i + 1;
			}

			i++;
		}

		else if (strcmpignorecase("-load", argv[i]) == 0)
		{
			if (i + 1 >= argc)
			{
				printf("You must specify a slot to load from\n");
				printf("Type %s -h for help\n", argv[0]);

				exit(1);
			}

			loadSlot = atoi(argv[i + 1]);

			i++;
		}

		else if (strcmpignorecase("-nojoystick", argv[i]) == 0)
		{
			game.disableJoystick = TRUE;
		}

		else if (strcmpignorecase("-joystick", argv[i]) == 0)
		{
			if (i + 1 >= argc)
			{
				printf("You must specify a joystick slot to use\n");
				printf("Type %s -h for help\n", argv[0]);

				exit(1);
			}

			joystick = atoi(argv[i + 1]);

			i++;
		}

		else if (strcmpignorecase("-showcredits", argv[i]) == 0)
		{
			showCredits = TRUE;
		}

		else if (strstr(argv[i], "-lang") != NULL)
		{
			if (i + 1 >= argc)
			{
				printf("You must specify a language to use\n");
				printf("Type %s -h for help\n", argv[0]);

				exit(1);
			}

			languageID = i + 1;

			i++;
		}

		else if (strstr(argv[i], "-h") != NULL || strstr(argv[i], "-help") != NULL)
		{
			printf("The Legend of Edgar options\n\n");
			printf("\t-record <filename>: Captures keyboard input\n");
			printf("\t-playback <filename>: Replays keyboard input\n");
			printf("\t-load <save_slot>: Loads the game in slot <save_slot>. Slots start at 0\n");
			printf("\t-nojoystick: Disables the joystick\n");
			printf("\t-joystick <joystick_slot>: Use joystick <joystick_slot>. Slots start at 0\n");
			printf("\t-showcredits: Shows the end credits\n");
			printf("\t-language <language_code>: Use language <language_code>. e.g. en_US, es, pl\n\n");

			exit(0);
		}

		#if DEV == 1
			else if (strcmpignorecase("-saveonexit", argv[i]) == 0)
			{
				game.saveOnExit = TRUE;
			}

			else if (strcmpignorecase("-bmpwrite", argv[i]) == 0)
			{
				setScreenshotDir(argv[i + 1]);

				i++;
			}

			else
			{
				mapID = i;
			}
		#endif
	}

	setLanguage("edgar", languageID == -1 ? NULL : argv[languageID]);
	printf("Numeric is %s\n", setlocale(LC_NUMERIC, "C"));
	printf("atof(2.75) is %f\n", atof("2.75"));

	/* Call the cleanup function when the program exits */

	atexit(cleanup);

	/* Start up SDL */

	init(_("The Legend of Edgar"), joystick);

	loadRequiredResources();

	if (replayingID != -1 && recordingID != -1)
	{
		showErrorAndExit("Cannot record and replay at the same time");
	}

	#if DEV == 0
		verifyVersion();
	#endif

	/* Initialise the game variables */

	freeGameResources();

	initGame();

	if (loadSlot == -1)
	{
		if (recordingID != -1)
		{
			setRecordData(argv[recordingID]);

			setMapFile(mapID == -1 ? "map01" : argv[mapID]);
		}

		else if (replayingID != -1)
		{
			setReplayData(argv[replayingID], TRUE);

			setMapFile(mapID == -1 ? "map01" : argv[mapID]);
		}

		if (mapID != -1)
		{
			startOnMap(argv[mapID]);
		}

		else if (game.firstRun == TRUE)
		{
			tutorial();
		}

		else
		{
			game.status = IN_TITLE;
		}
	}

	else
	{
		if (recordingID != -1)
		{
			game.gameType = RECORDING;
		}

		else if (replayingID != -1)
		{
			game.gameType = REPLAYING;
		}

		if (loadGame(loadSlot) == FALSE)
		{
			showErrorAndExit("No saved game in slot %d", loadSlot);
		}

		if (recordingID != -1)
		{
			setRecordData(argv[recordingID]);

			setMapFile(getMapFilename());
		}

		else if (replayingID != -1)
		{
			setReplayData(argv[replayingID], TRUE);
		}
	}

	/* Loop indefinitely for messages */

	game.startTicks = SDL_GetTicks();

	#if DEV == 1
		printf("DEV Version\n");
	#else
		printf("Production Version\n");
	#endif

	frameLimit = SDL_GetTicks() + game.fps;

	if (showCredits == TRUE)
	{
		game.status = IN_CREDITS;
	}

	while (go == TRUE)
	{
		getInput(game.gameType);

		switch (game.status)
		{
			case IN_TITLE:
				doTitle();
			break;

			case IN_GAME:
				freeCollisionGrid();

				clearDrawLayers();

				doGame();

				doPlayer();

				doInventory();

				doMap();

				doEntities();

				doDecorations();

				doCollisions();

				doHud();

				doDialogBox();

				processMedals();
			break;

			case IN_INVENTORY:
				doInventoryMenu();
			break;

			case IN_MENU:
				doMenu();
			break;

			case IN_CREDITS:
				freeCollisionGrid();

				clearDrawLayers();

				doGame();

				doCredits();

				doDecorations();

				doCollisions();
			break;

			default:
				doMenu();
			break;
		}

		draw();

		/* Sleep briefly to stop sucking up all the CPU time */

		delay(frameLimit);

		frameLimit = SDL_GetTicks() + game.fps;

		game.frames++;
	}

	/* Exit the program */

	exit(0);
}
Exemple #15
0
void Jogo::intro()
{
    Objeto logo(gui.logo_tex);
    logo.setPosition(gui.getWidth()/2, gui.getHeigth()/2.3);

    /*---Texto---*/
    sf::Clock clk_intro;
    int controlAlpha = 2;
    bool sobe = true;

    while(gui.tela.isOpen())
    {
        sf::Event evento;

        gui.limpaTela();

        while (gui.tela.pollEvent(evento))
        {
            switch(evento.type)
            {
            case(sf::Event::Closed):
                gui.tela.close();
                break;
            case(sf::Event::KeyPressed):
            {
                if(evento.key.code == sf::Keyboard::Escape)
                {
                    gui.tela.close();
                }
                else
                {
                    gui.inicio.play();
                    incrementaLevel();
                    sf::Time tempo = sf::milliseconds(500);
                    sf::sleep(tempo);
                    tutorial();

                    return;
                }
                break;
            }
            default:
                break;
            }
        }

        /*---Texto---*/
        sf::Time elapsed = clk_intro.getElapsedTime();

        if(elapsed.asSeconds() > 0.1)
        {
            if(sobe)
                controlAlpha++;
            else
                controlAlpha--;

            if(controlAlpha == 10 || controlAlpha == 2)
                sobe = !sobe;

            clk_intro.restart();
        }

        sf::Color color(100,100,100, 25 * controlAlpha);

        gui.limpaTela();

        gui.desenhaTexto("Pressione qualquer tecla para começar", 30, color, gui.getWidth()/2, gui.getHeigth()/1.2, true);

        gui.tela.draw(logo);
        gui.renderiza();
    }

}
Exemple #16
0
configure() {

void config_menu();

char abt = ' ', new_name[NAMESIZE];
int h,i, good;

pause_override = TRUE;

config_menu();

while( abt != 'X' && (carrDet() || ra.onConsole)){
  mPrintf("Selection: ");
  
  abt = (char) toupper(iChar());
  
  switch(abt) {
   case 'A' :
      if (!ra.expert) tutorial("wide.blb");
      ra.termWidth   = getNumber(" Terminal Width",         15, 132);
      --ra.termWidth;
      break;
   case 'B':   
      if (!ra.expert) tutorial("lineht.blb");
      ra.logBuf.pause_at = (ra.logBuf.pause_at & 0x80) |
        ((char) getNumber ("Screen Height in Lines (11-45): ", 11, 45) & 0x7f);
      break;
   case 'C':   
      if (!ra.expert) tutorial("lf.blb");
      sprintf(format, "\n Linefeed Added: %s\n ", 
              (ra.termLF ^= LFMASK) ? " Yes" : " No ");
      mPrintf(format);        
      break;
   case 'D':
      if (!ra.expert) tutorial("tab.blb");
      sprintf(format, "\n Tabs Sent: %s\n ", 
              (ra.termTab ^= TABMASK) ? " Yes" : " No");
      mPrintf(format);        
      break;
   case 'E':   
      if (!ra.expert) tutorial("lasto.blb");
      sprintf(format, "\n Show Last Old Message with New: %s \n  ", 
              (ra.lasto ^= LOMASK) ? " Yes " : " No");
      mPrintf(format);        
      break;
   case 'F':
      if (!ra.expert) tutorial("hlp.blb");
      sprintf(format, "\n Expert Mode On: %s\n ", 
              (ra.expert ^= EXPERT) ? " Yes " : " No");
      mPrintf(format);        
      break;
   case 'G':
      if (!ra.expert) tutorial("more.blb");
      sprintf(format, "\n Screen Pause is On: %s\n ", 
              (ra.termMore ^= MORE) ? " Yes" : " No");
      mPrintf(format);        
      if (ra.termMore) {
         if (getYesNo (" Pause Between Messages ") ) 
            ra.logBuf.pause_at |= 0x80;
         else
            ra.logBuf.pause_at &= 0x7f;
      }
      else ra.logBuf.pause_at &= 0x7f;         
      break;
   case 'H':
      if (!ra.expert) tutorial("pace.blb");
      sprintf(format, "\n Controlled Typeout is %s\n ",
             (ra.nopace ^= NOPACE) ? "Off" : "On");
      mPrintf(format);
      if (ra.nopace) ra.logBuf.lbnulls |= NOPACE;
      else ra.logBuf.lbnulls &=  ~NOPACE;
      break;
             
   case 'X': break;
   
   default: {
      if( !ra.loggedIn) return; 
      config_menu(); 
      break;
    }  
  }
}
storeLog();

pause_override = FALSE;

return TRUE;
}
Exemple #17
0
void Kolf::initGUI()
{
	newAction = KStdGameAction::gameNew(this, SLOT(newGame()), actionCollection());
	newAction->setText(newAction->text() + QString("..."));

	endAction = KStdGameAction::end(this, SLOT(closeGame()), actionCollection());
	printAction = KStdGameAction::print(this, SLOT(print()), actionCollection());

	(void) KStdGameAction::quit(this, SLOT(close()), actionCollection());
	saveAction = KStdAction::save(this, SLOT(save()), actionCollection(), "game_save");
	saveAction->setText(i18n("Save &Course"));
	saveAsAction = KStdAction::saveAs(this, SLOT(saveAs()), actionCollection(), "game_save_as");
	saveAsAction->setText(i18n("Save &Course As..."));

	saveGameAction = new KAction(i18n("&Save Game"), 0, this, SLOT(saveGame()), actionCollection(), "savegame");
	saveGameAsAction = new KAction(i18n("&Save Game As..."), 0, this, SLOT(saveGameAs()), actionCollection(), "savegameas");

	loadGameAction = KStdGameAction::load(this, SLOT(loadGame()), actionCollection());
	loadGameAction->setText(i18n("Load Saved Game..."));

	highScoreAction = KStdGameAction::highscores(this, SLOT(showHighScores()), actionCollection());

	editingAction = new KToggleAction(i18n("&Edit"), "pencil", CTRL+Key_E, this, SLOT(emptySlot()), actionCollection(), "editing");
	newHoleAction = new KAction(i18n("&New"), "filenew", CTRL+SHIFT+Key_N, this, SLOT(emptySlot()), actionCollection(), "newhole");
	clearHoleAction = new KAction(KStdGuiItem::clear().text(), "locationbar_erase", CTRL+Key_Delete, this, SLOT(emptySlot()), actionCollection(), "clearhole");
	resetHoleAction = new KAction(i18n("&Reset"), CTRL+Key_R, this, SLOT(emptySlot()), actionCollection(), "resethole");
	undoShotAction = KStdAction::undo(this, SLOT(emptySlot()), actionCollection(), "undoshot");
	undoShotAction->setText(i18n("&Undo Shot"));
	//replayShotAction = new KAction(i18n("&Replay Shot"), 0, this, SLOT(emptySlot()), actionCollection(), "replay");

	holeAction = new KListAction(i18n("Switch to Hole"), 0, this, SLOT(emptySlot()), actionCollection(), "switchhole");
	nextAction = new KAction(i18n("&Next Hole"), "forward", KStdAccel::shortcut(KStdAccel::Forward), this, SLOT(emptySlot()), actionCollection(), "nexthole");
	prevAction = new KAction(i18n("&Previous Hole"), "back", KStdAccel::shortcut(KStdAccel::Back), this, SLOT(emptySlot()), actionCollection(), "prevhole");
	firstAction = new KAction(i18n("&First Hole"), "gohome", KStdAccel::shortcut(KStdAccel::Home), this, SLOT(emptySlot()), actionCollection(), "firsthole");
	lastAction = new KAction(i18n("&Last Hole"), CTRL+SHIFT+Key_End, this, SLOT(emptySlot()), actionCollection(), "lasthole");
	randAction = new KAction(i18n("&Random Hole"), "goto", 0, this, SLOT(emptySlot()), actionCollection(), "randhole");

	useMouseAction = new KToggleAction(i18n("Enable &Mouse for Moving Putter"), 0, this, SLOT(emptySlot()), actionCollection(), "usemouse");
	useMouseAction->setCheckedState(i18n("Disable &Mouse for Moving Putter"));
	connect(useMouseAction, SIGNAL(toggled(bool)), this, SLOT(useMouseChanged(bool)));
	KConfig *config = kapp->config();
	config->setGroup("Settings");
	useMouseAction->setChecked(config->readBoolEntry("useMouse", true));

	useAdvancedPuttingAction = new KToggleAction(i18n("Enable &Advanced Putting"), 0, this, SLOT(emptySlot()), actionCollection(), "useadvancedputting");
	useAdvancedPuttingAction->setCheckedState(i18n("Disable &Advanced Putting"));
	connect(useAdvancedPuttingAction, SIGNAL(toggled(bool)), this, SLOT(useAdvancedPuttingChanged(bool)));
	useAdvancedPuttingAction->setChecked(config->readBoolEntry("useAdvancedPutting", false));

	showInfoAction = new KToggleAction(i18n("Show &Info"), "info", CTRL+Key_I, this, SLOT(emptySlot()), actionCollection(), "showinfo");
	showInfoAction->setCheckedState(i18n("Hide &Info"));
	connect(showInfoAction, SIGNAL(toggled(bool)), this, SLOT(showInfoChanged(bool)));
	showInfoAction->setChecked(config->readBoolEntry("showInfo", false));

	showGuideLineAction = new KToggleAction(i18n("Show Putter &Guideline"), 0, this, SLOT(emptySlot()), actionCollection(), "showguideline");
	showGuideLineAction->setCheckedState(i18n("Hide Putter &Guideline"));
	connect(showGuideLineAction, SIGNAL(toggled(bool)), this, SLOT(showGuideLineChanged(bool)));
	showGuideLineAction->setChecked(config->readBoolEntry("showGuideLine", true));

	KToggleAction *act=new KToggleAction(i18n("Enable All Dialog Boxes"), 0, this, SLOT(enableAllMessages()), actionCollection(), "enableAll");
	act->setCheckedState(i18n("Disable All Dialog Boxes"));

	soundAction = new KToggleAction(i18n("Play &Sounds"), 0, this, SLOT(emptySlot()), actionCollection(), "sound");
	connect(soundAction, SIGNAL(toggled(bool)), this, SLOT(soundChanged(bool)));
	soundAction->setChecked(config->readBoolEntry("sound", true));

	(void) new KAction(i18n("&Reload Plugins"), 0, this, SLOT(initPlugins()), actionCollection(), "reloadplugins");
	(void) new KAction(i18n("Show &Plugins"), 0, this, SLOT(showPlugins()), actionCollection(), "showplugins");

	aboutAction = new KAction(i18n("&About Course"), 0, this, SLOT(emptySlot()), actionCollection(), "aboutcourse");
	tutorialAction = new KAction(i18n("&Tutorial"), 0, this, SLOT(tutorial()), actionCollection(), "tutorial");

	statusBar();
	setupGUI();
}
Exemple #18
0
/* -------------------------------------------------------------------- */
void newUserFile(void)
{
    FILE           *fl;
    char      name[40];
    char     phone[30];
    label      surname;
    label        title;
    char      temp[85];
    char     dtstr[85];
/*  int    tempmaxtext; */ 
    int          clm=0;
    int            l=0;

    *name     ='\0';
    *phone    ='\0';
    *surname  ='\0';
    *title    ='\0';
    
    tutorial("newquest.blb");
    
    if (cfg.titles && cfg.entersur)
    {
        getNormStr("the title you desire",   title,  NAMESIZE, ECHO);
    }
    
    if (cfg.surnames && cfg.entersur)
    {
        getNormStr("the surname you desire", surname,    NAMESIZE, ECHO);
    }
    
    strcpy(logBuf.title,   title);
    strcpy(logBuf.surname, surname);

    strcpy(msgBuf->mbsur,   logBuf.surname);
    strcpy(msgBuf->mbtitle, logBuf.title);

    getNormStr("your full real name",        name,     40,       ECHO);

    if (name[0])
    {
        getNormStr("your phone number [(xxx)xxx-xxxx]", phone, 30, ECHO);
    }


    strcpy(msgBuf->mbto, "Sysop");
    strcpy(msgBuf->mbauth, logBuf.lbname);
    msgBuf->mbtext[0] = 0;

#ifdef GOODBYE
    tempmaxtext = cfg.maxtext;
    cfg.maxtext = 1024;
#endif

    getText();
    stripansi(msgBuf->mbtext);

#ifdef GOODBYE
    cfg.maxtext = tempmaxtext;
#endif
              
    if (changedir(cfg.homepath) == ERROR)  return;

    if ((fl = fopen("newuser.log", "at")) == NULL)
    {
        return;
    }
    strftime(dtstr, 79, (loggedIn) ? logBuf.vdstamp : cfg.vdatestamp, 0l);

    sprintf(temp, "\n %s\n", dtstr);
    fwrite(temp, strlen(temp), 1, fl);

    stripansi(title); 
    stripansi(surname);
    stripansi(name);
    stripansi(phone);


    if (surname[0] || title[0])
    {
        sprintf(temp, " Nym:       [%s] %s [%s]\n", 
                title, deansi(logBuf.lbname), surname);
    }
    else
    {
        sprintf(temp, " Nym:       %s\n",    deansi(logBuf.lbname) );
    }
    fwrite(temp, strlen(temp), 1, fl);

    sprintf(temp, " Real name: %s\n",             name );
    fwrite(temp, strlen(temp), 1, fl);

    sprintf(temp, " Phone:     %s\n",            phone );
    fwrite(temp, strlen(temp), 1, fl);

    sprintf(temp, " Baud:      %u\n",     bauds[speed] );
    fwrite(temp, strlen(temp), 1, fl);

    sprintf(temp, "\n");

    if(msgBuf->mbtext[0])   /* xPutStr(fl, msgBuf->mbtext); */
    {
        do
        {
            if((msgBuf->mbtext[l] == 32 || msgBuf->mbtext[l] == 9) && clm > 73)
            {
                fwrite(temp, strlen(temp), 1, fl);
                clm = 0;
                l++;
            }
            else
            {
                fputc(msgBuf->mbtext[l], fl);
                clm++;
                if(msgBuf->mbtext[l] == 10)
                    clm = 0;
                if(msgBuf->mbtext[l] == 9)
                    clm = clm + 7;
                l++;
            }
        } while(msgBuf->mbtext[l]);
    }

    fclose(fl);
    doCR();
}
Exemple #19
0
/* -------------------------------------------------------------------- */
void globalgroup(void)
{
    label groupname;
    int groupslot, i, yn, add, logNo;

    mPrintf("(A/R/[B]): ");

    switch (toupper( iCharNE() ))
    {
    case 'A':
        mPrintf("Add\n ");
        add = 1;
        break;
    
    case 'R':
        mPrintf("Remove\n ");
        add = 2;
        break;
    
    case '?':
        tutorial("grpglob.mnu");
        return;
        
    case 'B':
    case 10:
    case 13:
    default:
        mPrintf("Both\n ");
        add = 0;
        break;
    }

    getString("group", groupname, NAMESIZE, FALSE, ECHO, "");

    groupslot = partialgroup(groupname);

    if ( grpBuf.group[groupslot].hidden && !ingroup(groupslot) )
        groupslot = ERROR;

    if ( groupslot == ERROR || !strlen(groupname) )
    {
        mPrintf("\n No such group.");
        return;
    }

    if ( grpBuf.group[groupslot].lockout && !sysop )
    {
        mPrintf("\n Group is locked.");
        return;
    }

    for (i = 0; i < cfg.MAXLOGTAB; i++)
    {
        if (logTab[i].ltpwhash != 0 && logTab[i].ltnmhash !=0)
        {
            logNo=logTab[i].ltlogSlot;
            getLog(&lBuf, logNo);
            
            /* Get out.. */
            outFlag = OUTOK;
            if (mAbort(FALSE)) break;
            outFlag = IMPERVIOUS;
            
            if (lBuf.groups[groupslot] == grpBuf.group[groupslot].groupgen)
            {
                if(add == 2 || add == 0)
                {
                    mPrintf(" 3%s0", lBuf.lbname);
                    yn=getYesNo("Remove from group", 0+3);
                    if (yn == 2)
                    {
                        SaveAideMess();
                        return;
                    }
      
                    if (yn)
                    {
                        lBuf.groups[groupslot] =
                            (uchar)((grpBuf.group[groupslot].groupgen
                          + (MAXGROUPGEN - 1)) % MAXGROUPGEN);
          
                        sprintf(msgBuf->mbtext,
                            "%s kicked out of group %s by %s",
                            lBuf.lbname,
                            grpBuf.group[groupslot].groupname,
                            logBuf.lbname );
           
                        trap(msgBuf->mbtext, T_SYSOP);
          
                        amPrintf(" %s\n", msgBuf->mbtext);
                    }
                }
            }
            else
            {
                if (add == 0 || add == 1)
                {
                    mPrintf(" 3%s0", lBuf.lbname);
                    yn=getYesNo("Add to group", 0+3);
                    if (yn == 2)
                    {
                        SaveAideMess();
                        return;
                    }
                    if (yn)
                    {
                        lBuf.groups[groupslot] =
                            grpBuf.group[groupslot].groupgen;
           
                        sprintf(msgBuf->mbtext,
                            "%s added to group %s by %s",
                            lBuf.lbname,
                            grpBuf.group[groupslot].groupname,
                            logBuf.lbname );
         
                        trap(msgBuf->mbtext, T_AIDE);
           
                        amPrintf(" %s\n",msgBuf->mbtext);
                    }
                }
            }
  
            putLog(&lBuf, logNo);
     
            /* see if it is us: */
            if (loggedIn  &&  strcmpi(logBuf.lbname, lBuf.lbname) == SAMESTRING)
            {
                logBuf.groups[groupslot] = lBuf.groups[groupslot];
            }
        }
    }

    SaveAideMess();
}
Exemple #20
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    _has_unsaved_data(true),
    _current_file(""),
    _can_run(false),
    _is_running(false),
    _is_debug_input(false)
{
    ui->setupUi(this);

    initStyles();
    updateWindowTitle();
    redoAvailable(false);
    undoAvailable(false);
    copyAvailable(false);



    _window = this;

    ui->debugRun->setVisible(false);
    ui->runWidget->setVisible(false);

    registerFileType(tr("Yad.Markov.File"),
                     tr("Markov Algorithm File"),
                     ".yad",
                     1);

    updateDebugMenu();

    //Connect MainWindow menu
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionUndo, SIGNAL(triggered()), this, SIGNAL(undo()));
    connect(ui->actionRedo, SIGNAL(triggered()), this, SIGNAL(redo()));
    connect(ui->actionSelect_All, SIGNAL(triggered()), this, SIGNAL(selectAll()));
    connect(ui->actionCopy, SIGNAL(triggered()), this, SIGNAL(copy()));
    connect(ui->actionPaste, SIGNAL(triggered()), this, SIGNAL(paste()));
    connect(ui->actionCut, SIGNAL(triggered()), this, SIGNAL(cut()));
    connect(ui->actionDelete, SIGNAL(triggered()), this, SIGNAL(deleteSelection()));
    connect(ui->actionNew, SIGNAL(triggered()), this, SIGNAL(newFile()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SIGNAL(open()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SIGNAL(save()));
    connect(ui->actionSave_As, SIGNAL(triggered()), this, SIGNAL(saveAs()));
    connect(ui->actionTutorial, SIGNAL(triggered()), this, SLOT(tutorial()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));

    //Connect InputWidget and HistoryManager
    HistoryManager* history_manager = HistoryManager::getInstance();

    connect(ui->input, SIGNAL(addToHistory(QString)),
            history_manager, SLOT(addToHistory(QString)));
    connect(history_manager, SIGNAL(wordSelected(QString)),
            ui->input, SLOT(setInput(QString)));

    //Connect HistoryWidget and HistoryManager
    connect(ui->history, SIGNAL(inputWordSelected(QString)),
            history_manager, SIGNAL(wordSelected(QString)));
    connect(ui->history, SIGNAL(removeFromHistory(QString)),
            history_manager, SLOT(removeFromHistory(QString)));
    connect(history_manager, SIGNAL(historyChanged(QVector<QString>)),
            ui->history, SLOT(historyChanged(QVector<QString>)));

    //Connect MainWindows and FileManager
    FileManager* file_manager = FileManager::getInstance();
    connect(this, SIGNAL(newFile()), file_manager, SLOT(newFile()));
    connect(this, SIGNAL(open()), file_manager, SLOT(open()));
    connect(this, SIGNAL(save()), file_manager, SLOT(save()));
    connect(this, SIGNAL(saveAs()), file_manager, SLOT(saveAs()));
    connect(file_manager, SIGNAL(hasUnsavedData(bool)),
            this, SLOT(hasUnsavedData(bool)));
    connect(file_manager, SIGNAL(fileNameChanged(QString)),
            this, SLOT(fileNameChanged(QString)));

    //Connect MainWindows and EditorWindowWidget
    connect(this, SIGNAL(undo()), ui->editorWindow, SLOT(undo()));
    connect(this, SIGNAL(redo()), ui->editorWindow, SLOT(redo()));
    connect(this, SIGNAL(selectAll()), ui->editorWindow, SLOT(selectAll()));
    connect(this, SIGNAL(copy()), ui->editorWindow, SLOT(copy()));
    connect(this, SIGNAL(paste()), ui->editorWindow, SLOT(paste()));
    connect(this, SIGNAL(cut()), ui->editorWindow, SLOT(cut()));
    connect(this, SIGNAL(deleteSelection()),
            ui->editorWindow, SLOT(deleteSelection()));

    connect(ui->editorWindow, SIGNAL(redoAvailable(bool)),
            this, SLOT(redoAvailable(bool)));
    connect(ui->editorWindow, SIGNAL(undoAvailable(bool)),
            this, SLOT(undoAvailable(bool)));
    connect(ui->editorWindow, SIGNAL(copyAvailable(bool)),
            this, SLOT(copyAvailable(bool)));

    //Connect InputWidget and MarkovRunManager
    MarkovRunManager* run_manager = MarkovRunManager::getInstance();

    connect(ui->input, SIGNAL(run(QString)),
            run_manager, SLOT(runWithoutDebug(QString)));
    connect(ui->input, SIGNAL(runWithDebug(QString)),
            run_manager, SLOT(runWithDebug(QString)));
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            ui->input, SLOT(runStarted()));
    connect(ui->input, SIGNAL(runWithDebugStepByStep(QString)),
            run_manager, SLOT(runWithDebugStepByStep(QString)));
    connect(run_manager, SIGNAL(debugStarted(QString)),
            ui->input, SLOT(runStarted()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)),
            ui->input, SLOT(runFinished()));
    connect(run_manager, SIGNAL(canRunSourceCode(bool)),
            ui->input, SLOT(canRunAlgorithm(bool)));

    //Connect SourceCodeManager and EditorWindowWidget
    SourceCodeManager* source_manager = SourceCodeManager::getInstance();
    connect(source_manager, SIGNAL(newSourceCodeWasLoaded(QString)),
            ui->editorWindow, SLOT(newSourceCode(QString)));
    connect(ui->editorWindow, SIGNAL(sourceCodeChanged(QString)),
            source_manager, SLOT(setSourceCode(QString)));

    //Connect InputWidget and FileManager
    connect(ui->input, SIGNAL(save()), file_manager, SLOT(save()));

    //Connect MarkovRunManager and EditorWindowWidget
    connect(ui->editorWindow, SIGNAL(canRun(bool)),
            run_manager, SLOT(setCanRunSourceCode(bool)));
    connect(ui->editorWindow, SIGNAL(markovAlgorithmChanged(MarkovAlgorithm)),
            run_manager, SLOT(setAlgorithm(MarkovAlgorithm)));

    //Connect SourceCodeManager and FileManager
    connect(file_manager, SIGNAL(newSourceCodeLoaded(QString)),
            source_manager, SLOT(setNewSourceCodeFromFile(QString)));
    connect(source_manager, SIGNAL(sourceCodeChanged(QString)),
            file_manager, SLOT(sourceCodeChanged()));

    //Connect FileManager and HistoryManager
    connect(file_manager, SIGNAL(newHistoryLoaded(QVector<QString>)),
            this, SLOT(newHistoryLoaded(QVector<QString>)));
    connect(history_manager, SIGNAL(historyChanged(QVector<QString>)),
            file_manager, SLOT(historyChanged()));

    //Connect RunWidget and MarkovRunManager
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            ui->runWidget, SLOT(runStarted(QString)));
    connect(run_manager, SIGNAL(runStepsMade(int)),
            ui->runWidget, SLOT(runStepsMade(int)));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            ui->runWidget, SLOT(runFailed(QString,RunError,int)));
    connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)),
            ui->runWidget, SLOT(runSuccess(QString,QString,int)));
    connect(run_manager, SIGNAL(debugStarted(QString)),
            ui->runWidget, SLOT(hide()));

    //Connect DebugRunWidget and MarkovRunManager
    connect(ui->debugRun, SIGNAL(nextStepClicked()),
            run_manager, SLOT(debugNextStep()));
    connect(ui->debugRun, SIGNAL(continueClicked()),
            run_manager, SLOT(debugContinue()));
    connect(ui->debugRun, SIGNAL(stopClicked()),
            run_manager, SLOT(debugStop()));

    connect(run_manager, SIGNAL(debugStarted(QString)),
            ui->debugRun, SLOT(debugStarted(QString)));
    connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)),
            ui->debugRun, SLOT(debugSuccess(QString,QString,int)));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            ui->debugRun, SLOT(debugFailed(QString,RunError,int)));
    connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)),
            ui->debugRun, SLOT(debugStepFinished(int,QString,QString,MarkovRule)));
    connect(run_manager, SIGNAL(debugBreakPointReached(int)),
            ui->debugRun, SLOT(breakPointReached(int)));
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            ui->debugRun, SLOT(hide()));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            ui->runWidget, SLOT(hide()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            ui->debugRun, SLOT(hide()));

    //Connect DebugRunWidget and EditorWindowWidget
    connect(ui->debugRun, SIGNAL(removeBreakPoint()),
            ui->editorWindow, SLOT(removeLineHighlight()));
    connect(ui->debugRun, SIGNAL(showBreakPoint(int)),
            ui->editorWindow, SLOT(showLineHighlight(int)));

    //Connect MarkovRunManager and EditorWindowWidget
    connect(ui->editorWindow, SIGNAL(breakPointAdded(int)),
            run_manager, SLOT(addBreakPoint(int)));
    connect(ui->editorWindow, SIGNAL(breakPointRemoved(int)),
            run_manager, SLOT(removeBreakPoint(int)));

    //Connect top menu
    connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
            this, SLOT(runStarted()));
    connect(run_manager, SIGNAL(debugStarted(QString)),
            this, SLOT(runStarted()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)),
            this, SLOT(runFinished()));
    connect(run_manager, SIGNAL(canRunSourceCode(bool)),
            this, SLOT(canRunAlgorithm(bool)));
    connect(run_manager, SIGNAL(debugBreakPointReached(int)),
            this, SLOT(debugInputStarted()));
    connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)),
            this, SLOT(debugInputFinished()));

    connect(ui->actionRun, SIGNAL(triggered()),
            ui->input, SLOT(runCliked()));
    connect(ui->actionDebug, SIGNAL(triggered()),
            ui->input, SLOT(runWithDebugClicked()));
    connect(ui->actionNext_Step, SIGNAL(triggered()),
            run_manager, SLOT(debugNextStep()));
    connect(ui->actionContinue, SIGNAL(triggered()),
            run_manager, SLOT(debugContinue()));
    connect(ui->actionStop_Debug, SIGNAL(triggered()),
            run_manager, SLOT(debugStop()));
    connect(ui->actionDebug_Step_By_Step, SIGNAL(triggered()),
            ui->input, SLOT(runWithDebugStepByStepClicked()));

    //Read file to open from command line
    QStringList arguments = QCoreApplication::arguments();
    if(arguments.size() >= 2)
    {
        QString file_name = arguments.at(1);
        FileManager::getInstance()->openFile(file_name);
    }
    else
    {
        source_manager->setNewSourceCodeFromFile(tr("//Alphabet\nT = {a, b}\n\n//Rules\nab -> a\na ->. b"));
    }

}
Exemple #21
0
void updatebalance(void)
{
    float drain;
    long timestamp, diff;

    if ( thisAccount.special[ hour() ] && !specialTime)
    {
        specialTime = TRUE;
        doCR();
        if (loggedIn)
        {
            mPrintf("Special time is now beginning, you have no time limit.");
            doCR();
        }
    }

    if (specialTime &&                  /* if it's no longer special    */
       !thisAccount.special[ hour() ] ) /* time....                     */
    {
        doCR();

        if(loggedIn)
        {
            mPrintf("Special time is over. You have %.0f %s left today.",
                logBuf.credits, (logBuf.credits == 1)?"minute":"minutes" );
            doCR();
        }

        specialTime = FALSE;

        time(&lasttime);
    }

    if (specialTime)    /* don't charge them for FREE time!             */
        return;


    /* get current time stamp */
    time(&timestamp);

    diff = timestamp - lasttime;

    /* If the time was set wrong..... */
    if (diff < 0)
      diff = 0;
    
    drain = (float)((float)diff / (float)60);

    logBuf.credits = logBuf.credits - drain;

    time(&lasttime);

    if (!gotCarrier() || (whichIO == CONSOLE)) return;

    if (logBuf.credits < (float)5)
    {
        doCR();
        mPrintf(" Only %.0f %s left today!", logBuf.credits,
            (logBuf.credits == 1)?"minute":"minutes" );
        doCR();
    }

    if (  !thisAccount.days[ dayofweek() ]   /* if times up of it's no  */
    ||    !thisAccount.hours[ hour()     ]   /* login time for them..   */
    ||     logBuf.credits <= (float)0    )
    {
        tutorial("goodbye.blb");

        terminate(TRUE, 1);
    }
}
Exemple #22
0
char modIn() {
   char getMod(), getCh(), KBReady();
   char i, s[4],  ch;
   unsigned    hi, lo, zz, c=0;
   void get_baud();
   time_t hh;
      
   hi = 20; /*(HITIMEOUT * ra.megaHz);*/ /* about 4 ra.minutes  */
   lo = 0xFF;

   startTimer();
   hh = time(NULL);
   while (TRUE) {


       fix_rollover();

      if ((ra.whichIO==MODEM) && (c=carrDet()) != ra.modStat) {
    /* carrier changed   */
    if (c)  {     /* carrier present   */
       doStatusLine(S_MSGS, "Carrier Detect");
       ra.haveCarrier = TRUE;
       pause(40);
       ra.guess = 3;
       ra.modStat     = c;
       ra.newCarrier  = TRUE;
       ra.rtry      = 5;
       getDaTime();
       ra.lhour = ra.hour;
       ra.lminute = ra.minute;
       return(0);
       }
    else {
       sleep(1);        /* confirm it's not a glitch */
       if (!carrDet()) {   /* check again */
     doStatusLine(S_MSGS, "Carrier Loss");
     ra.haveCarrier     = FALSE;
     ra.modStat     = FALSE;
     ra.justLostCarrier = TRUE;
     terminate(TRUE);
/*     hangUp();*/
     return(0);
     }
       }
    }
      if (mIready()) {
    if (ra.haveCarrier) {
       c = (getMod() & 0x7F);
       if (ra.whichIO == MODEM)   return(c);
       }       
    else {       /* no carrier, so it must be  */
       if (ra.whichIO == MODEM) {  /* a modem result code.    */
          get_baud();
          if (ra.baud == -1) /* return 0;*/ {
             if (ra.lockedport && carrDet() /* ra.haveCarrier*/ ) 
                ra.baud = 2400; /* make believe it's 2400 */
             else return 0;
             }   
          if (ra.baud < RING && ra.baud > -1) { 
            neverLoggedIn = TRUE;
            getDaTime();

            sprintf(format, "%2d|%02d|%02d %02d:%02d ",
                    ra.year,
                    ra.month,
                    ra.date,
                    ra.hour,
                    ra.minute         );
           sprintf(&ra.call_record.time_day,"%-18s", format);
         }
          timeout = time(NULL) + ra.timeout/4;
       }
       }
    }

      if (KBReady()) {
    c = bioskey(0); /* getCh(); */
    if(!(c & 0xFF)) {
       /* must be a special key */
       switch(c >> 8){
         case F10 :
            for_sysop = TRUE;
            for ( zz = 0; zz < 7; zz++) {
              delay(500);
              oChar(BELL);
            }  
            doCR();
            doCR();
            tutorial("warning.blb");
            doCR();
            doCR();
            break;
         case F9  :
            mPrintf("%^&*(&^GYFGR^&{{}}{{{}}{{{}}}|+*(^}&^");
            byeflag = FALSE;
            if (carrDet() )terminate(TRUE);
            break;
         }
         return(0);
     }
    ch = (char) c;            
    if (ra.whichIO == CONSOLE) {
     if (ch != SPECIAL) return(ch);
     else { ra.whichIO = MODEM;
       timeout = time(NULL) + (ra.loggedIn ? ra.timeout : ra.timeout/4);
       doStatusLine(WHICH_IO, "MODEM  ");
       if (!carrDet()) doOnhook();
       if(!ra.haveCarrier)doStatusLine(S_MSGS, "Waiting...");
       return(0);
          }
     }
    else {
       if (ch == SPECIAL) {
     doStatusLine(WHICH_IO, "console");
     doStatusLine(S_MSGS,   "                         ");
     ra.whichIO = CONSOLE;
     if (!ra.loggedIn) setUp(FALSE);
     if (!carrDet()) doOffhook();
     timeout = time(NULL) + (ra.loggedIn ? ra.timeout : ra.timeout/4);
     return(0);
     }
       }
    }

    /* check for no input.  (Short-circuit evaluation, remember!) */
    if ( (ra.whichIO==MODEM  &&  ra.haveCarrier) || ra.onConsole ) {
       if( (time(NULL)) > timeout) {
       terminate(TRUE);
       return(0);
       }
   }
   
    } /*while TRUE */
}  /*finished*/