예제 #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //Init
    isSqlSetted = false;

    //status tips
    ui->actionDataBase_Info->setStatusTip(tr("Set Database Info."));
    ui->actionLogin->setStatusTip(tr("Get Login Dialog."));
    ui->actionExit->setStatusTip(tr("Exit the Window."));
    ui->actionLogout->setStatusTip(tr("Logout the account."));

    //signals and slots
    connect(ui->actionDataBase_Info, SIGNAL(triggered()), this, SLOT(getDBInfo()));
    connect(ui->actionLogin, SIGNAL(triggered()), this, SLOT(login()));
    connect(ui->actionLogout, SIGNAL(triggered()), this, SLOT(reset()));

    connect(ui->infoWidget, SIGNAL(loadProfile()), this, SLOT(loadProfile()));
    connect(ui->infoWidget, SIGNAL(loadScore()), this, SLOT(loadScore()));
    connect(ui->infoWidget, SIGNAL(loadCurriculumSchedule()), this, SLOT(loadCurriculumSchedule()));
    connect(ui->infoWidget, SIGNAL(loadElective()), this, SLOT(loadElective()));
    connect(ui->infoWidget, SIGNAL(loadPlan()), this, SLOT(loadPlan()));
    connect(ui->infoWidget, SIGNAL(loadRecord()), this, SLOT(loadRecord()));
    connect(ui->infoWidget, SIGNAL(chgPwd()), this, SLOT(changePwd()));

//    dbInfo.hostName = "localhost";
//    dbInfo.DBName = "Handin";
//    dbInfo.userName = "******";
//    dbInfo.password = "******";

    //login();

}
예제 #2
0
파일: file.c 프로젝트: skarl86/gostop_c
void loadPlayer(char* fname, char* fname_player_head_pae, char* fname_score, player_info *load_player)
{
	FILE *load = NULL;

	char id[2]; // 알파벳으로 구성된 플레이어 고유 번호.
	char isSwing; // 흔듦
	char isChongtong; // 총통
	int total_score; // 총 점수.
	int go_count; // GO 카운트.
	int total_score_when_go; // GO했을때 점수.
	int money; // 사용자 돈.

	load = fopen(fname, "rt");
	if (load == NULL) puts("load fopen() fail!");

	while(fscanf(load, "%s %c %c %d %d %d %d\n", id, &isSwing, &isChongtong, &total_score,
												&go_count, &total_score_when_go, &money) != EOF)
	{
		strcpy(load_player->id, id);
		load_player->isSwing = isSwing - '0';
		load_player->isChongtong = isChongtong - '0';
		load_player->total_score = total_score;
		load_player->go_count = go_count;
		load_player->money = money;
		printf("%s %d %d %d %d %d\n",
				load_player->id,
				load_player->isSwing,
				load_player->isChongtong,
				load_player->total_score,
				load_player->go_count,
				load_player->money);
	}

	puts("load player pae");

	//load_player->head_pae = (P_HWATOO)malloc(sizeof(HWATOO));
	load_player->score = (P_SCORE)malloc(sizeof(SCORE));
	loadPae(fname_player_head_pae, &(load_player->head_pae));

	puts("load player score");
	loadScore(fname_score, load_player->score);
	puts("loadScore success!");
	fclose(load);
}
예제 #3
0
파일: main.cpp 프로젝트: Apodus/language
int main(int argc, char** argv) {
	
	if(argc >= 3) {
		int currentArgument = 0;
		std::string userID = argv[++currentArgument];
		std::string secondArg = argv[++currentArgument];

		std::vector<std::string> settings;
		loadSettings(userID, settings);

		if(secondArg == "HAS_SETTING") {
			std::string askedSetting = argv[++currentArgument];
			for(size_t i=0; i<settings.size(); ++i) {
				if(askedSetting == settings[i]) {
					std::cout << "checked";
					return 0;
				}
			}
			return 0;
		}
		else if(secondArg == "GET_SCORE") {
			std::cout << loadScore(userID);
			return 0;
		}

		std::vector<Verb> verbs;

		{
			std::string line;
			std::ifstream in("data/verbs.list");
			while(in.good() && !in.eof()) {
				getline(in, line);
				if(line == "VERB_BEGIN") {
					Verb v;
					if(v.read(in, settings))
						verbs.push_back(v);
				}
			}
		}

		
		if(secondArg == "PUZZLE1") {
			// get some simple puzzles
			std::cout << "<form action=\"index.php\" method=\"post\">\n";
			srand(static_cast<unsigned>(time(0)));

			for(int i=0; i<5; ++i) {
				int index = rand() % verbs.size();
				Verb& v = verbs[index];

				if(v.values.size() < 2)
					break;

				int propertyIndex = rand() % v.values.size();
				auto it = v.values.begin();
				for(int i=0; i<propertyIndex; ++i) ++it;
				std::string property = it->first;
				std::string value = it->second;

				int propertyIndex2 = rand() % (v.values.size()-1);
				if(propertyIndex2 >= propertyIndex) ++propertyIndex2;
				auto it2 = v.values.begin();
				for(int i=0; i<propertyIndex2; ++i) ++it2;
				outputSinglePuzzle(index, property, value, it2->first);
			}
			std::cout << "<table><tr><th>Submit:</th><td><input type=\"submit\"></td></tr></table>\n";
			std::cout << "</form>\n";
		}
		else if(secondArg == "GRADE1") {
			// grade opponent's answer to a single puzzle!
			std::stringstream ss(argv[++currentArgument]);
			int index;
			ss >> index;
			std::string propertyName = argv[++currentArgument];
			std::string propertyValue = argv[++currentArgument];

			const Verb& v = verbs[index];
			const std::string& val = v.values.find(propertyName)->second;
			
			long long userScore = loadScore(userID);
			int score = outputSingleGrade(v, propertyName, val, propertyValue);
			if(score > 0)
				userScore += score;
			else
				userScore /= 2;
			saveScore(userID, userScore);
			std::cout << " score: " << userScore << "<br/>" << std::endl;
		}
int
main(int argc, char *argv[])
{
	char buffer[512];
    struct node* head = NULL;
    struct dlb_node* dlbHead = NULL;
    SDL_Surface *screen;
    struct sprite* letters = NULL;

	/* buffer sounds */
	int audio_rate = MIX_DEFAULT_FREQUENCY;
	Uint16 audio_format = MIX_DEFAULT_FORMAT;//AUDIO_S16
	int audio_channels = 2;//1
	int audio_buffers = 512;//256

	/* seed the random generator */
	srand((unsigned int)time(NULL));

	/* identify the resource locale */
	init_locale(argc, argv);
    if (language[strlen(language)-1] != '/')
        strcat(language, "/");

	/* create dictionary */
    strcpy(txt, language);
	if (!dlb_create(&dlbHead, strcat(txt, "wordlist.txt"))) {
        Error("failed to open word list file");
        exit(1);
    }
	
#ifdef demo
	/*read in demo info*/
	sprintf(buffer,"globaldata/agdemo.cfg");
	if(!loadCFG(buffer,&conf))
	{
		//fprintf(stderr,"config file location %s\n",buffer);
		fprintf(stderr,"unable to read configuration, using defaults\n");
		//exit(1);
	}
#endif

/* read hi-scores */
#ifdef demo
	sprintf(buffer,"/media/internal/appdata/com.cribme.aghddemo/ag-hiscore");
#else
	sprintf(buffer,"/media/internal/appdata/com.cribme.aghd/ag-hiscore");
#endif
	if(!loadScore(buffer,hiscore)){
		fprintf(stderr,"unable to read hi-scores, using defaults\n");
	}
	if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0){
		Error("Unable to init SDL: %s", SDL_GetError());
		exit(1);
	}

	atexit(SDL_Quit);

	screen = SDL_SetVideoMode(800, 600, 16, 0);//(800, 600, 16, SDL_HWSURFACE|SDL_DOUBLEBUF)
	if (screen == NULL)
	{
		Error("Unable to set 800x600 video: %s", SDL_GetError());
		exit(1);
	}

	SDL_WM_SetCaption("Anagramarama", "ANAGRAMARAMA");

	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
		Error("unable to open audio!");
		exit(1);
	}

	bufferSounds(&soundCache);

	/* cache in-game graphics */
	strcpy(txt, language);
	letterBank = SDL_LoadBMP(strcat(txt,"images/letterBank.bmp"));
	strcpy(txt, language);
	smallLetterBank = SDL_LoadBMP(strcat(txt,"images/smallLetterBank.bmp"));
	strcpy(txt, language);
	numberBank = SDL_LoadBMP(strcat(txt,"images/numberBank.bmp"));
	/* load locale specific configuration */
	strcpy(txt, language);
	loadConfig(strcat(txt, "config.ini"));

	newGame(&head, dlbHead, screen, &letters);

	gameLoop(&head, dlbHead, screen, &letters);

	/* tidy up and exit */

	Mix_CloseAudio();
	clearSoundBuffer(&soundCache);
	dlb_free(dlbHead);
	destroyLetters(&letters);
	destroyAnswers(&head);
	SDL_FreeSurface(screen);
	SDL_FreeSurface(letterBank);
	SDL_FreeSurface(smallLetterBank);
	SDL_FreeSurface(numberBank);
	/*SDL_Quit(); */
	return 0;
}