aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.cpp24
-rw-r--r--src/entities.cpp7
-rw-r--r--src/gameplay.cpp10
-rw-r--r--src/ui.cpp72
4 files changed, 93 insertions, 20 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 9f9b05e..3ef1a3e 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -11,15 +11,13 @@ extern float VOLUME_MASTER;
extern float VOLUME_MUSIC;
XMLDocument xml;
+XMLElement *scr;
+XMLElement *vol;
-void readConfig(void){
- XMLElement *scr;
- XMLElement *vol;
-
+void readConfig(){
unsigned int uval;
bool bval;
- //float fval;
-
+
xml.LoadFile("config/settings.xml");
scr = xml.FirstChildElement("screen");
@@ -47,9 +45,15 @@ void readConfig(void){
}
-void updateConfig(void){
- XMLElement *vol = xml.FirstChildElement("volume")->FirstChildElement("master")->ToElement();
- vol->SetAttribute("volume",VOLUME_MASTER);
-
+void updateConfig(){
+ vol->FirstChildElement("master")->SetAttribute("volume",VOLUME_MASTER);
+ vol->FirstChildElement("music")->SetAttribute("volume",VOLUME_MUSIC);
+
+ Mix_Volume(0,VOLUME_MASTER);
+ Mix_VolumeMusic(VOLUME_MUSIC);
+
+}
+
+void saveConfig(){
xml.SaveFile("config/settings.xml", false);
}
diff --git a/src/entities.cpp b/src/entities.cpp
index caf3d59..b36ea3d 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -19,7 +19,7 @@ std::string sTexLoc[] = { "assets/townhall.png",
"assets/house1.png",
"assets/fountain1.png",
"assets/lampPost1.png",
- "assets/brazzier.png"};
+ "assets/brazier.png"};
GLuint waterTex;
@@ -42,7 +42,7 @@ void getRandomName(Entity *e){
tempNum = rand() % max;
names.seekg(0,names.beg);
-
+
for(unsigned int i=0;i<tempNum;i++)
names.getline(bufs,32);
@@ -404,7 +404,8 @@ const char *randomDialog[] = {
"You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.",
"I want to have the wallpaper in our house changed. It doesn\'t really fit the environment.",
"Frig.",
- "The sine of theta equals the opposite over the hypotenuese."
+ "The sine of theta equals the opposite over the hypotenuese.",
+ "Did you know the developers spelt brazier as brazzier."
};
void NPC::interact(){ //have the npc's interact back to the player
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index bf37256..8a24056 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -238,15 +238,15 @@ void initEverything(void){
atexit(destroyEverything);
std::cout << "Hey";
- pauseMenu.items.push_back(ui::createParentButton({-256/2,0},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Resume")));
- pauseMenu.items.push_back(ui::createChildButton({-256/2,-100},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Options")));
- pauseMenu.items.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"), ui::quitGame));
- pauseMenu.items.push_back(ui::createButton({-256/2,-300},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Segfault"), segFault));
+ pauseMenu.items.push_back(ui::createParentButton({-256/2,0},{256,75},{0.0f,0.0f,0.0f}, "Resume"));
+ pauseMenu.items.push_back(ui::createChildButton({-256/2,-100},{256,75},{0.0f,0.0f,0.0f}, "Options"));
+ pauseMenu.items.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, "Save and Quit", ui::quitGame));
+ pauseMenu.items.push_back(ui::createButton({-256/2,-300},{256,75},{0.0f,0.0f,0.0f}, "Segfault", segFault));
pauseMenu.child = &optionsMenu;
pauseMenu.parent = NULL;
- optionsMenu.items.push_back(ui::createSlider({-512/2,100}, {512,50}, {0.0f, 0.0f, 0.0f}, 0, 100, (const char*)("Shit"), &VOLUME_MASTER));
+ optionsMenu.items.push_back(ui::createSlider({-512/2,100}, {512,50}, {0.0f, 0.0f, 0.0f}, 0, 100, "Shit", &VOLUME_MASTER));
optionsMenu.child = NULL;
optionsMenu.parent = &pauseMenu;
// optionsMenu.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"), );
diff --git a/src/ui.cpp b/src/ui.cpp
index 65e1673..a075037 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -227,7 +227,8 @@ namespace ui {
buf[j*4 ]=fontColor[0];
buf[j*4+1]=fontColor[1];
buf[j*4+2]=fontColor[2];
- buf[j*4+3]=ftf->glyph->bitmap.buffer[j] ? 255 : 0;
+ //buf[j*4+3]=ftf->glyph->bitmap.buffer[j] == 255 ? 255 : 0;
+ buf[j*4+3]=ftf->glyph->bitmap.buffer[j];
}
ftexwh[i-33].x=ftf->glyph->bitmap.width;
@@ -640,6 +641,7 @@ namespace ui {
void quitGame(){
gameRunning = false;
updateConfig();
+ saveConfig();
}
void quitMenu(){
@@ -723,6 +725,8 @@ namespace ui {
*/
void drawMenu(Menu *menu){
+
+ setFontSize(20);
SDL_Event e;
mouse.x=premouse.x+offset.x-(SCREEN_WIDTH/2);
@@ -871,7 +875,70 @@ namespace ui {
}
}
}
+ setFontSize(16);
}
+
+ void takeScreenshot(GLubyte* pixels){
+ GLubyte bgr[SCREEN_WIDTH*SCREEN_HEIGHT*3];
+ for(uint x = 0; x < SCREEN_WIDTH*SCREEN_HEIGHT*3; x+=3){
+ bgr[x] = pixels[x+2];
+ bgr[x+1] = pixels[x+1];
+ bgr[x+2] = pixels[x];
+ }
+
+ time_t epoch = time(NULL);
+ struct tm* timen = localtime(&epoch);
+
+ std::string name = "screenshots/";
+ name += std::to_string(1900 + timen->tm_year) += "-";
+ name += std::to_string(timen->tm_mon + 1) += "-";
+ name += std::to_string(timen->tm_mday) += "_";
+ name += std::to_string(timen->tm_hour) += "-";
+ name += std::to_string(timen->tm_min) += "-";
+ name += std::to_string(timen->tm_sec);
+ name += ".bmp";
+ FILE* bmp = fopen(name.c_str(), "w+");
+
+ unsigned long header_size = sizeof(BITMAPFILEHEADER) +
+ sizeof(BITMAPINFOHEADER);
+
+ BITMAPFILEHEADER bmfh;
+ BITMAPINFOHEADER bmih;
+
+ memset(&bmfh, 0, sizeof(BITMAPFILEHEADER));
+ memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
+
+ bmfh.bfType = 0x4d42;
+
+ bmfh.bfOffBits = 0x36;
+ bmfh.bfSize = header_size;
+ bmfh.bfReserved1 = 0;
+ bmfh.bfReserved2 = 0;
+
+
+ bmih.biSize = sizeof(BITMAPINFOHEADER);
+ bmih.biBitCount = 24;
+
+ bmih.biClrImportant = 0;
+ bmih.biClrUsed = 0;
+
+ bmih.biCompression = 0;
+
+ bmih.biWidth = SCREEN_WIDTH;
+ bmih.biHeight = SCREEN_HEIGHT;
+
+ bmih.biPlanes = 1;
+ bmih.biSizeImage = 0;
+
+ bmih.biXPelsPerMeter = 0x0ec4;
+ bmih.biYPelsPerMeter = 0x0ec4;
+
+ fwrite(&bmfh, 1,sizeof(BITMAPFILEHEADER),bmp);
+ fwrite(&bmih, 1,sizeof(BITMAPINFOHEADER),bmp);
+ fwrite(&bgr, 1,3*SCREEN_WIDTH*SCREEN_HEIGHT,bmp);
+
+ }
+
void dialogAdvance(void){
unsigned char i;
if(!typeOutDone){
@@ -1123,11 +1190,12 @@ DONE:
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
break;
case SDLK_F12:
- std::cout << "Took screenshot" << std::endl;
// Make the BYTE array, factor of 3 because it's RBG.
static GLubyte* pixels = new GLubyte[ 3 * SCREEN_WIDTH * SCREEN_HEIGHT];
glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
+ takeScreenshot(pixels);
+ std::cout << "Took screenshot" << std::endl;
break;
default:
break;