Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 62 additions & 42 deletions include/ced_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,76 @@ using namespace std;
extern CEDsettings setting;
extern GLfloat window_width;

void drawHelpString (const string & str, float x,float y){ //format help strings strings: "[<key>] <description>"
void drawHelpString(const std::string& str, float x, float y) {
unsigned int i;
// float x1=x;
// float y1=y;
// if( x1 < 0.0){
// x1=0.;
// }
// if( y1 < 0.0){
// y1=0.;
// }
//
// glRasterPos2f(x1,y1);

glRasterPos2f(x,y);

// Set OpenGL raster position for bitmap OR transform for stroke
if (setting.font <= 2) {
glRasterPos2f(x, y); // for bitmap fonts
} else {
glPushMatrix();

float scale;
if (setting.font == 3) {
scale = 0.3f;
} else if (setting.font == 4) {
scale = 0.6f;
} else {
scale = 1.0f; // fallback or unused
}

// Position in screen coords (x, y)
// Stroke fonts are ~119 units high in font-space
float font_height = 0.05f;

// Translate to (x, y), then adjust up so text appears aligned
glTranslatef(x, y, 0.0f);

// Flip Y *before* drawing, then move up by height
glScalef(scale, -scale, scale);
glTranslatef(0.0f, -font_height, 0.0f);

}

int monospace = 0;
for (i = 0; str[i]; i++){
if(str[i] == '['){

for (i = 0; i < str.size(); i++) {
if (str[i] == '[') {
monospace = 1;
if(setting.font == 0){
glutBitmapCharacter (GLUT_BITMAP_HELVETICA_10, '[');
}else if(setting.font == 1){
glutBitmapCharacter (GLUT_BITMAP_HELVETICA_12, '[');
}else if(setting.font == 2){
glutBitmapCharacter (GLUT_BITMAP_HELVETICA_18, '[');
if (setting.font <= 2) {
if (setting.font == 0) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, '[');
else if (setting.font == 1) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, '[');
else glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, '[');
} else {
glutStrokeCharacter(GLUT_STROKE_ROMAN, '[');
}
i++;
}
else if(str[i] == ']'){
monospace = 0;
continue;
} else if (str[i] == ']') {
monospace = 0;
}
if(monospace){
if(setting.font == 0){
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, str[i]);
}else if(setting.font == 1){
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, str[i]);
}else if(setting.font == 2){
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, str[i]);

if (monospace) {
if (setting.font <= 2) {
if (setting.font == 0) glutBitmapCharacter(GLUT_BITMAP_8_BY_13, str[i]);
else if (setting.font == 1) glutBitmapCharacter(GLUT_BITMAP_8_BY_13, str[i]);
else glutBitmapCharacter(GLUT_BITMAP_9_BY_15, str[i]);
} else {
glutStrokeCharacter(GLUT_STROKE_ROMAN, str[i]);
}
}else{
//glutBitmapCharacter (GLUT_BITMAP_HELVETICA_10, str[i]);
//glutBitmapCharacter ( GLUT_BITMAP_HELVETICA_12 , str[i]);
//glutBitmapCharacter ( GLUT_BITMAP_HELVETICA_18 , str[i]);
if(setting.font == 0){
glutBitmapCharacter (GLUT_BITMAP_HELVETICA_10, str[i]);
}else if(setting.font == 1){
glutBitmapCharacter (GLUT_BITMAP_HELVETICA_12, str[i]);
}else if(setting.font == 2){
glutBitmapCharacter (GLUT_BITMAP_HELVETICA_18, str[i]);
} else {
if (setting.font <= 2) {
if (setting.font == 0) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, str[i]);
else if (setting.font == 1) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
else glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]);
} else {
glutStrokeCharacter(GLUT_STROKE_ROMAN, str[i]);
}
}
}

if (setting.font > 2) {
glPopMatrix(); // restore matrix after stroke drawing
}
}

void drawStringBig (char *s){
Expand Down Expand Up @@ -800,6 +818,8 @@ class CED_PopUpMenu{
#define FONT0 2010
#define FONT1 2011
#define FONT2 2012
#define FONT3 2013
#define FONT4 2014

#define UNDO 2312

Expand Down
25 changes: 25 additions & 0 deletions src/server/glced.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,15 @@ void selectFromMenu(int id){ //hauke
//buildMainMenu();
break;

case FONT3:
setting.font=3;
//buildMainMenu();
break;

case FONT4:
setting.font=4;
//buildMainMenu();
break;

case UNDO:
setting=setting_old[0];
Expand Down Expand Up @@ -3632,6 +3641,12 @@ void buildPopUpMenu(int x, int y){
if(setting.font==2){
width=300;
}
if(setting.font==3){
width=600;
}
if(setting.font==4){
width=1200;
}

int pos_y=popupmenu->size()*height;

Expand Down Expand Up @@ -3994,6 +4009,16 @@ void buildMainMenu(void){
}else{
font->addItem(new CED_SubSubMenu("[ ] Big",FONT2));
}
if(setting.font == 3){
font->addItem(new CED_SubSubMenu("[X] Bigger",FONT3));
}else{
font->addItem(new CED_SubSubMenu("[ ] Bigger",FONT3));
}
if(setting.font == 4){
font->addItem(new CED_SubSubMenu("[X] Huge",FONT4));
}else{
font->addItem(new CED_SubSubMenu("[ ] Huge",FONT4));
}
settings->addItem(font);


Expand Down