Hello to whoever can help me,
I am making a game using C++ and I came across this console library called PDCurses that is supposed to help with writing console programs. The thing is, I just cannot find the right way to include it in my project. I looked up many various tutorials, which most were very outdated (I even searched through StackOverflow here). The ones that were somewhat current did not match my issue. I pasted my code below if it helps any. Whatever help I can get I would appreciate very much. Thanks!
The Infinitide.cpp:
// The Infinitide.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "InfinitideResources.h"
// Current console instance
//HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
//HWND hInstance = GetConsoleWindow();
//
//TCHAR screenCache[75][45];
//int screenWidth = 45, screenHeight = 75;
//
//int oldCurrentPercLoaded;
xml_node<> * baseData;
WINDOW *initscr(void);
int flash(void);
int updateConsoleColor(int clr) {
if (clr > 15 || clr < 0) {
return 1; // clrIndex is out of range
}
//SetConsoleTextAttribute(hConsole, clr);
return 0;
}
int setConsoleColor(int clrIndex, COLORREF rgb) {
if (clrIndex > 15 || clrIndex < 0) {
return 1; // clrIndex is out of range
}
CONSOLE_SCREEN_BUFFER_INFOEX info;
info.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
//GetConsoleScreenBufferInfoEx(hConsole, &info);
info.ColorTable[clrIndex] = rgb;
//SetConsoleScreenBufferInfoEx(hConsole, &info);
return 0;
}
int setConsoleColors() {
int ii = 0;
for (COLORREF i : colors) {
setConsoleColor(ii, i);
ii++;
}
updateConsoleColor(3);
return 0;
}
int clearConsole() {
/*for (int i = 0; i < screenHeight; i++) {
cout << '\n';
}*/
return 0;
}
int initWindow() {
//setConsoleColors();
/*RECT r;
GetWindowRect(hInstance, &r);
MoveWindow(hInstance, r.left, r.top, DEFAULT_WND_WIDTH, DEFAULT_WND_HEIGHT, true);*/
return 0;
}
int loadBaseData() {
//initWindow();
xml_document<> doc;
xml_node<> * root_node;
ifstream baseDataFile("TheInfinitideBaseData.xml");
vector<char> buffer((istreambuf_iterator<char>(baseDataFile)), istreambuf_iterator<char>());
buffer.push_back('\0');
doc.parse<0>(&buffer[0]);
root_node = doc.first_node("root");
baseData = root_node;
return 0;
}
int loadingBar(int percLoaded, int size, string msg) {
//clear();
// Loading title
cout << msg << endl;
cout << "[";
for (int i = 0; i < floor(percLoaded / 100 * size); i++) {
cout << "|";
}
for (int i = 0; i < floor((100 - percLoaded) / 100 * size); i++) {
cout << " ";
}
cout << "]" << endl;
return 0;
}
int loadScreen() {
return 0;
}
int load() {
int stepsCompleted = 0;
const int stepsTotal = 1;
int currentPercLoaded;
//oldCurrentPercLoaded = -1;
/*while (stepsCompleted < stepsTotal) {
currentPercLoaded = stepsCompleted / stepsTotal * 100;
loadingBar(currentPercLoaded, DEFAULT_LOAD_BAR_SIZE, DEFAULT_LOAD_MSG);
}*/
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
// Setup
load();
return 0;
}
InfinitideResources.h:
#include "stdafx.h"
#define DEFAULT_DATA string = ""
const int DEFAULT_WND_WIDTH = 800;
const int DEFAULT_WND_HEIGHT = 500;
const COLORREF colors[] = {
RGB(0, 0, 0), // Black (0)
RGB(77, 77, 77), // Dark Gray (1)
RGB(179, 179, 179), // Light Gray (2)
RGB(255, 255, 255), // White (3)
RGB(255, 0, 0), // Red (4)
RGB(128, 0, 0), // Dark Red (5)
RGB(0, 255, 0), // Green (6)
RGB(0, 128, 0), // Dark Green (7)
RGB(0, 128, 255), // Blue (8)
RGB(0, 64, 128), // Dark Blue (9)
RGB(255, 255, 0), // Yellow (10)
RGB(128, 128, 0), // Dark Yellow (11)
RGB(255, 0, 255), // Purple (12)
RGB(128, 0, 128), // Dark Purple (13)
RGB(255, 191, 0), // Orange (14)
RGB(128, 94, 0) // Brown (15)
};
string DEFAULT_LOAD_MSG = "Loading...";
const int DEFAULT_LOAD_BAR_SIZE = 20;
stdafx.h:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#include <fstream>
#include <vector>
#include <Windows.h>
#include <utility>
#include <consoleapi.h>
#include <iostream>
#include <string>
#include <curses.h>
#include <curspriv.h>
#include <panel.h>
#include <term.h>
#include <pdcwin.h>
#include <rapidxml\rapidxml.hpp>
using namespace rapidxml;
using namespace std;
Note: I am using Visual Studio 2013 on Windows 10.
Aucun commentaire:
Enregistrer un commentaire