fixing c++ string literal and narrowing warnings
Former-commit-id: e92f153b516ab0fce55a9695ba91a2398f5ff719
This commit is contained in:
parent
e198fffbd3
commit
83f2d6aa30
|
@ -59,7 +59,8 @@ void AppData::update() {
|
||||||
fd = setupConnection(c);
|
fd = setupConnection(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
modesReadFromClient(&modes, c,"",decodeBinMessage);
|
char empty;
|
||||||
|
modesReadFromClient(&modes, c, &empty,decodeBinMessage);
|
||||||
|
|
||||||
interactiveRemoveStaleAircrafts(&modes);
|
interactiveRemoveStaleAircrafts(&modes);
|
||||||
|
|
||||||
|
|
37
View.cpp
37
View.cpp
|
@ -195,7 +195,7 @@ int View::outOfBounds(int x, int y) {
|
||||||
// Font stuff
|
// Font stuff
|
||||||
//
|
//
|
||||||
|
|
||||||
TTF_Font* View::loadFont(char *name, int size)
|
TTF_Font* View::loadFont(const char *name, int size)
|
||||||
{
|
{
|
||||||
TTF_Font *font = TTF_OpenFont(name, size);
|
TTF_Font *font = TTF_OpenFont(name, size);
|
||||||
|
|
||||||
|
@ -304,20 +304,20 @@ void View::font_init() {
|
||||||
style.buttonColor = lightblue;
|
style.buttonColor = lightblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::drawString(char * text, int x, int y, TTF_Font *font, SDL_Color color)
|
void View::drawString(std::string text, int x, int y, TTF_Font *font, SDL_Color color)
|
||||||
{
|
{
|
||||||
if(!strlen(text)) {
|
if(!text.length()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
SDL_Rect dest;
|
SDL_Rect dest;
|
||||||
|
|
||||||
surface = TTF_RenderUTF8_Solid(font, text, color);
|
surface = TTF_RenderUTF8_Solid(font, text.c_str(), color);
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
{
|
{
|
||||||
printf("Couldn't create String %s: %s\n", text, SDL_GetError());
|
printf("Couldn't create String %s: %s\n", text.c_str(), SDL_GetError());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -333,19 +333,19 @@ void View::drawString(char * text, int x, int y, TTF_Font *font, SDL_Color color
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::drawStringBG(char * text, int x, int y, TTF_Font *font, SDL_Color color, SDL_Color bgColor) {
|
void View::drawStringBG(std::string text, int x, int y, TTF_Font *font, SDL_Color color, SDL_Color bgColor) {
|
||||||
if(!strlen(text)) {
|
if(!text.length()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
SDL_Rect dest;
|
SDL_Rect dest;
|
||||||
|
|
||||||
surface = TTF_RenderUTF8_Shaded(font, text, color, bgColor);
|
surface = TTF_RenderUTF8_Shaded(font, text.c_str(), color, bgColor);
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
{
|
{
|
||||||
printf("Couldn't create String %s: %s\n", text, SDL_GetError());
|
printf("Couldn't create String %s: %s\n", text.c_str(), SDL_GetError());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -365,9 +365,9 @@ void View::drawStringBG(char * text, int x, int y, TTF_Font *font, SDL_Color col
|
||||||
// Status boxes
|
// Status boxes
|
||||||
//
|
//
|
||||||
|
|
||||||
void View::drawStatusBox(int *left, int *top, char *label, char *message, SDL_Color color) {
|
void View::drawStatusBox(int *left, int *top, std::string label, std::string message, SDL_Color color) {
|
||||||
int labelWidth = (strlen(label) + ((strlen(label) > 0 ) ? 1 : 0)) * labelFontWidth;
|
int labelWidth = (label.length() + ((label.length() > 0 ) ? 1 : 0)) * labelFontWidth;
|
||||||
int messageWidth = (strlen(message) + ((strlen(message) > 0 ) ? 1 : 0)) * messageFontWidth;
|
int messageWidth = (message.length() + ((message.length() > 0 ) ? 1 : 0)) * messageFontWidth;
|
||||||
|
|
||||||
if(*left + labelWidth + messageWidth + PAD > screen_width) {
|
if(*left + labelWidth + messageWidth + PAD > screen_width) {
|
||||||
*left = PAD;
|
*left = PAD;
|
||||||
|
@ -821,8 +821,17 @@ void View::drawPlaneText(Aircraft *p) {
|
||||||
|
|
||||||
if(maxCharCount > 1) {
|
if(maxCharCount > 1) {
|
||||||
|
|
||||||
Sint16 vx[4] = {p->cx, p->cx + (p->x - p->cx) / 2, p->x, p->x};
|
Sint16 vx[4] = {
|
||||||
Sint16 vy[4] = {p->cy, p->cy + (p->y - p->cy) / 2, p->y - mapFontHeight, p->y};
|
static_cast<Sint16>(p->cx),
|
||||||
|
static_cast<Sint16>(p->cx + (p->x - p->cx) / 2),
|
||||||
|
static_cast<Sint16>(p->x),
|
||||||
|
static_cast<Sint16>(p->x)};
|
||||||
|
|
||||||
|
Sint16 vy[4] = {
|
||||||
|
static_cast<Sint16>(p->cy),
|
||||||
|
static_cast<Sint16>(p->cy + (p->y - p->cy) / 2),
|
||||||
|
static_cast<Sint16>(p->y - mapFontHeight),
|
||||||
|
static_cast<Sint16>(p->y)};
|
||||||
|
|
||||||
if(p->cy > p->y + currentLine * mapFontHeight) {
|
if(p->cy > p->y + currentLine * mapFontHeight) {
|
||||||
vy[2] = p->y + currentLine * mapFontHeight + mapFontHeight;
|
vy[2] = p->y + currentLine * mapFontHeight + mapFontHeight;
|
||||||
|
|
11
View.h
11
View.h
|
@ -6,6 +6,7 @@
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#include "SDL2/SDL_ttf.h"
|
#include "SDL2/SDL_ttf.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//defs - should all move to config file setup
|
//defs - should all move to config file setup
|
||||||
#define ROUND_RADIUS 3 //radius of text box corners
|
#define ROUND_RADIUS 3 //radius of text box corners
|
||||||
|
@ -68,11 +69,11 @@ class View {
|
||||||
float dx_mult;
|
float dx_mult;
|
||||||
float dy_mult;
|
float dy_mult;
|
||||||
|
|
||||||
TTF_Font* loadFont(char *name, int size);
|
TTF_Font* loadFont(const char *name, int size);
|
||||||
void closeFont(TTF_Font *font);
|
void closeFont(TTF_Font *font);
|
||||||
void drawString(char * text, int x, int y, TTF_Font *font, SDL_Color color);
|
void drawString(std::string text, int x, int y, TTF_Font *font, SDL_Color color);
|
||||||
void drawStringBG(char * text, int x, int y, TTF_Font *font, SDL_Color color, SDL_Color bgColor);
|
void drawStringBG(std::string text, int x, int y, TTF_Font *font, SDL_Color color, SDL_Color bgColor);
|
||||||
void drawStatusBox(int *left, int *top, char *label, char *message, SDL_Color color);
|
void drawStatusBox(int *left, int *top, std::string label, std::string message, SDL_Color color);
|
||||||
void drawStatus();
|
void drawStatus();
|
||||||
|
|
||||||
Aircraft *selectedAircraft;
|
Aircraft *selectedAircraft;
|
||||||
|
@ -131,7 +132,7 @@ class View {
|
||||||
int mapMoved;
|
int mapMoved;
|
||||||
int mapRedraw;
|
int mapRedraw;
|
||||||
int mapAnimating;
|
int mapAnimating;
|
||||||
|
|
||||||
float currentLon;
|
float currentLon;
|
||||||
float currentLat;
|
float currentLat;
|
||||||
std::chrono::high_resolution_clock::time_point lastFrameTime;
|
std::chrono::high_resolution_clock::time_point lastFrameTime;
|
||||||
|
|
Loading…
Reference in a new issue