imageform.cpp 1.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "imageform.h"

void Form::postRandom()
{
    
    myfont.drawString("Occupation: " + RandomOcc,600,180);
    myfont.drawString("Hobby: " + RandomHob,600,280);
    myfont.drawString("Wealth: " + RandomWea,600,380);
    myfont.drawString("Dislikes: " + RandomDis,600,480);
    
};

void Form::updateRandom()
{
    RandomOcc = Occupation[ofRandom(Occupation.size())];
    RandomHob = Hobby[ofRandom(Hobby.size())];
    RandomWea = Wealth[ofRandom(Wealth.size())];
    RandomDis = Dislikes[ofRandom(Dislikes.size())];
};

void Form::updateFields()
{
	if (FanMode && !SciMode) 
	{
		myfont.load("mael.ttf", 24);
		Occupation = scanFiles("Occupation_Fan.txt");
		Hobby = scanFiles("Hobby_Fan.txt");
	}
	else if (!FanMode && SciMode)
	{
		myfont.load("alienencounters.ttf", 24);
		Occupation = scanFiles("Occupation_Sci.txt");
		Hobby = scanFiles("Hobby_Sci.txt");
	}
	else if (!FanMode && !SciMode)
	{
		myfont.load("arial.ttf", 24);
		Occupation = scanFiles("Occupation.txt");
		Hobby = scanFiles("Hobby.txt");
	}
	else 
	{
		myfont.load("arial.ttf", 24);
		Occupation = scanFiles("Occupation.txt");
		Hobby = scanFiles("Hobby.txt");
	}
    
    Wealth = scanFiles("Wealth.txt");
    
    Dislikes = scanFiles("Dislikes.txt");
   
};

std::vector<std::string> Form::scanFiles(std::string filename)
{

    std::vector<std::string> array;
    ofBuffer buffer = ofBufferFromFile(filename);
    for (auto line : buffer.getLines()){
        array.push_back(line);
    }
    return array;
}

std::vector<std::string> Form::addFiles(std::vector<std::string> results, std::string filename)
{
	ofBuffer buffer = ofBufferFromFile(filename);
	for (auto line : buffer.getLines()) {
		results.push_back(line);
	}
	return results;
}

void Form::startFanMode() 
{
	SciMode = false;
	FanMode = true;
	updateFields();
	updateRandom();
}

void Form::startSciMode()
{
	FanMode = false;
	SciMode = true;
	updateFields();
	updateRandom();
}

void Form::startRegMode()
{
	FanMode = false;
	SciMode = false;
	updateFields();
	updateRandom();
}