Beispiel #1
0
static void ShowAllKeys(int index, int change)
{
	int x1, x2, y1, y2;
	
	x1 = CenterX((TextCharWidth('a') * 10)) / 2;
	x2 = x1 * 3;
	
	y1 = (SCREEN_HEIGHT / 2) - (TextHeight() * 10);
	y2 = (SCREEN_HEIGHT / 2) - (TextHeight() * 2);
	
	DisplayKeys(x1, x2, y1, "Player One", &gPlayer1Data, index, change);
	DisplayKeys(x1, x2, y2, "Player Two", &gPlayer2Data, index - 6, change - 6);
	
	y2 += TextHeight() * 8;
	
	TextStringAt(x1, y2, "Map");
	
	if (change == 12)
		DisplayMenuItem(x2, y2, SELECTKEY, index == 12);
	else
		DisplayMenuItem(x2, y2, SDL_GetKeyName(gOptions.mapKey), index == 12);
	
#define DONE	"Done"
	
	y2 += TextHeight () * 2;
	
	DisplayMenuItem(CenterX(TextWidth(DONE)), y2, DONE, index == 13);
}
Beispiel #2
0
static int MainMenu(int x, int index, int cmd)
{
	int i;
	int y;
	static int selection[2] = { MODE_DONE, MODE_DONE };

	if (cmd & (CMD_BUTTON1 | CMD_BUTTON2)) {
		PlaySound(SND_BANG, 0, 255);
		return selection[index];
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > MODE_SELECTNAME) {
			selection[index]--;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == MODE_SELECTNAME) {
			selection[index] = MODE_DONE;
			PlaySound(SND_SWITCH, 0, 255);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < MODE_DONE) {
			selection[index]++;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == MODE_DONE) {
			selection[index] = MODE_SELECTNAME;
			PlaySound(SND_SWITCH, 0, 255);				
		}
	}

	y = CenterY((TextHeight() * MENU_COUNT));

	for (i = 1; i < MENU_COUNT; i++)
		DisplayMenuItem(x, y + i * TextHeight(), mainMenu[i],
				selection[index] == i);

	return MODE_MAIN;
}
Beispiel #3
0
void PlayerStatus(int placement, struct PlayerData *data, TActor * p)
{
	char s[50];

	int flags = TEXT_TOP;

	if (placement == PLACE_LEFT)	flags |= TEXT_LEFT;
	if (placement == PLACE_RIGHT)	flags |= TEXT_RIGHT;

	//TextStringAt(x, 5, data->name);
	TextStringSpecial(data->name, flags, 5, 5);
	if (!gCampaign.dogFight)
		sprintf(s, "Score: %d", data->score);
	else
		s[0] = 0;
	if (p) {
		TextStringSpecial(s, flags, 5, 5 + 2 + 2 * TextHeight());
		//TextStringAt(x, 5 + 2 + 2 * TextHeight(), s);
		TextStringSpecial(gunDesc[p->gun].gunName, flags, 5, 5 + 1 + TextHeight());
		//TextStringAt(x, 5 + 1 + TextHeight(), gunDesc[p->gun].gunName);
		sprintf(s, "%d hp", p->health);
		TextStringSpecial(s, flags, 5, 5 + 3 + 3 * TextHeight());
		//TextStringAt(x, 5 + 3 + 3 * TextHeight(), s);
	} else
		TextStringSpecial(s, flags, 5, 5 + 1 * TextHeight());
		//TextStringAt(x, 5 + 1 + TextHeight(), s);
}
Beispiel #4
0
static int TemplateSelection(int loadFlag, int x, int index,
			     struct PlayerData *data, int cmd)
{
	int i;
	int y;
	static int selection[2] = { 0, 0 };

	if (cmd & CMD_BUTTON1) {
		if (loadFlag)
			UseTemplate(index, data,
				    &templates[selection[index]]);
		else
			SaveTemplate(data, &templates[selection[index]]);
		PlaySound(rand() % SND_COUNT, 0, 255);
		return 0;
	} else if (cmd & CMD_BUTTON2) {
		PlaySound(rand() % SND_COUNT, 0, 255);
		return 0;
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > 0) {
			selection[index]--;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == 0) {
			selection[index] = MAX_TEMPLATE - 1;
			PlaySound(SND_SWITCH, 0, 255);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < MAX_TEMPLATE - 1) {
			selection[index]++;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == MAX_TEMPLATE - 1) {
			selection[index] = 0;
			PlaySound(SND_SWITCH, 0, 255);
		}
	}

	y = CenterY((TextHeight() * MAX_TEMPLATE));

	if (!loadFlag) {
		TextStringAt(x, y - 4 - TextHeight(), "Save ");
		TextString(data->name);
		TextString("...");
	}

	for (i = 0; i < MAX_TEMPLATE; i++)
		DisplayMenuItem(x, y + i * TextHeight(),
				templates[i].name, i == selection[index]);

	return 1;
}
void
AllShowingTextView::FrameResized(float width, float height)
{
	float minHeight = TextHeight(0, CountLines() - 1);
	SetExplicitMinSize(BSize(B_SIZE_UNSET, minHeight));
	BTextView::FrameResized(width, minHeight);
}
Beispiel #6
0
/*--------------------------------------------------------------------------*/
PegRadioButton::PegRadioButton(SIGNED iLeft, SIGNED iTop,
     const PEGCHAR *Text, WORD wId, WORD wStyle) :
     PegButton(wId, wStyle),
     PegTextThing(Text, wStyle & TT_COPY, PEG_RBUTTON_FONT)
{
    Type(TYPE_RADIOBUTTON);

    SetSignals(SIGMASK(PSF_DOT_ON));

    mReal.wLeft = iLeft;
    mReal.wTop = iTop;

    SIGNED iHeight = TextHeight(lsTEST, mpFont);
    if (gbRadioOnBitmap.wHeight > iHeight)
    {
        iHeight = gbRadioOnBitmap.wHeight;
    }
    iHeight += 4;

    if (Text)
    {
        mReal.wRight = mReal.wLeft + TextWidth(Text, mpFont) + 2;
        mReal.wRight += gbRadioOnBitmap.wWidth + RBUTTON_SPACING;
        mReal.wBottom = mReal.wTop + iHeight;
    }
    else
    {
        mReal.wRight = mReal.wLeft + 3;
        mReal.wBottom = mReal.wTop + iHeight;
    }
    mClient = mReal;
}
Beispiel #7
0
void Style::FreezeDefaultStyles() {
    const Default *d;
    for(d = &(Defaults[0]); d->h.v; d++) {
        CnfFreezeColor(Color(d->h), CnfColor(d->cnfPrefix));
        CnfFreezeFloat((float)Width(d->h), CnfWidth(d->cnfPrefix));
        CnfFreezeFloat((float)TextHeight(d->h), CnfTextHeight(d->cnfPrefix));
    }
}
Beispiel #8
0
static int AppearanceSelection(const char **menu, int menuCount,
			       int x, int index,
			       struct PlayerData *data, int *property,
			       int cmd, int *selection)
{
	int y;
	int i;

	debug(D_NORMAL, "\n");

	if (cmd & (CMD_BUTTON1 | CMD_BUTTON2)) {
		PlaySound(SND_MACHINEGUN, 0, 255);
		return 0;
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > 0) {
			selection[index]--;
			*property = selection[index];
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == 0) {
			selection[index] = menuCount - 1;
			*property = selection[index];
			PlaySound(SND_SWITCH, 0, 255);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < menuCount - 1) {
			selection[index]++;
			*property = selection[index];
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == menuCount - 1) {
			selection[index] = 0;
			*property = selection[index];
			PlaySound(SND_SWITCH, 0, 255);
		}
	}

	SetPlayer(index, data);

	y = CenterY((menuCount * TextHeight()));

	for (i = 0; i < menuCount; i++)
		DisplayMenuItem(x, y + i * TextHeight(), menu[i],
				i == selection[index]);

	return 1;
}
Beispiel #9
0
/*--------------------------------------------------------------------------*/
void PegChart::RecalcLayout(BOOL bRedraw /*=TRUE*/)
{
    mChartRegion = mClient;
    
    if(mwExStyle & CS_DRAWXTICS)
    {
        mChartRegion.wBottom -= mwMajorTicSize;
    }

    if(mwExStyle & CS_DRAWYTICS)
    {
        mChartRegion.wLeft += mwMajorTicSize;

		if(mwExStyle & CS_DUALYTICS)
		{
			mChartRegion.wRight -= mwMajorTicSize;
		}
    }

    if (mwExStyle & CS_DRAWYLABELS)
    {
		SIGNED iSkipHeight = TextHeight(lsTEST, mpFont);
		iSkipHeight++;
		iSkipHeight >>= 1;
		mChartRegion.wTop += iSkipHeight;

		if(!(mwExStyle & CS_DRAWXLABELS))
		{
			mChartRegion.wBottom -= iSkipHeight;
		}
        
        if(mwYLabelWidth == 0)
		{
			PEGCHAR cBuffer[20];
			_ltoa(mlMinY, cBuffer, 10);
			SIGNED iMinWidth = TextWidth(cBuffer, mpFont);
			//_ltoa(mlMinY,cBuffer,10);
			_ltoa(mlMaxY, cBuffer, 10);
			SIGNED iMaxWidth = TextWidth(cBuffer, mpFont);
			/*_ltoa(mlMinY,cBuffer,10);*/
			/*_ltoa(mlMaxY,cBuffer,10);*/
			mChartRegion.wLeft += 
                iMinWidth > iMaxWidth ? iMinWidth : iMaxWidth;
            mChartRegion.wLeft += 2;

            if(mwExStyle & CS_DUALYLABELS)
            {
                mChartRegion.wRight -= 
                    iMinWidth > iMaxWidth ? iMinWidth : iMaxWidth;
                mChartRegion.wRight -= 2;
            }
		}
		else
		{
			mChartRegion.wLeft += mwYLabelWidth;
		}
    }
Beispiel #10
0
void Legend::Draw()
{
    INFO0;
    if (!legend_.GetListOfPrimitives() || legend_.GetListOfPrimitives()->GetSize() == 0) return;
    legend_.SetCornerRadius(TextHeight() / Rectangle().Width() / 6);
    legend_.SetBorderSize(0);
    legend_.SetLineWidth(0);
    legend_.Draw("arc");
}
Beispiel #11
0
int MiniStyledTextCtrl::GetLineFromPosition(const wxPoint &pt)
{
    int line = GetFirstVisibleLine();

    int lh = TextHeight(line);
    if (lh>0)
        line += pt.y/lh;
    return line;
}
Beispiel #12
0
void
AllShowingTextView::GetHeightForWidth(float width, float* min, float* max,
	float* preferred)
{
	BTextView::GetHeightForWidth(width, min, max, preferred);
	float minHeight = TextHeight(0, CountLines() - 1);
	if (min)
		*min = minHeight;
}
Beispiel #13
0
void DisplayMenuAt(int x, int y, const char **table, int count, int index)
{
	int i;

	for (i = 0; i < count; i++) {
		DisplayMenuItem(x, y + i * TextHeight(), table[i], i == index);
	}
	
	return;
}
Beispiel #14
0
static void Save(int asCode)
{
	char filename[128];
//      char drive[_MAX_DRIVE];
	char dir[96];
	char name[32];
//      char ext[_MAX_EXT];
	char c;
	int i;

	strcpy(filename, lastFile);
	while (1) {
		memset(GetDstScreen(), 58, 64000);
		TextStringAt(125, 50, "Save as:");
		TextGoto(125, 50 + TextHeight());
		TextChar('\020');
		TextString(filename);
		TextChar('\021');
		vsync();
		CopyToScreen();

		c = GetKey();
		switch (c) {
		case ENTER:
			if (!filename[0])
				break;
			if (asCode) {
				SaveCampaignAsC(filename, name, &campaign);
			} else {
				SaveCampaign(filename, &campaign);
			}
			fileChanged = 0;
			return;

		case ESCAPE:
			return;

		case BACKSPACE:
			if (filename[0])
				filename[strlen(filename) - 1] = 0;
			break;

		default:
			if (strlen(filename) == sizeof(filename) - 1)
				break;
			c = toupper(c);
			if ((c >= 'A' && c <= 'Z') ||
			    c == '-' || c == '_' || c == '\\') {
				i = strlen(filename);
				filename[i + 1] = 0;
				filename[i] = c;
			}
		}
	}
}
Beispiel #15
0
void message(const char *text, ...)
{
	char tmp[256];
	va_list vl;
	va_start(vl, text);
	vsprintf(tmp, text, vl);
	va_end(vl);
	tmp[strlen(tmp)] = 0;
        
	int th = TextHeight(fontstruct);
	int char_width = TextWidth(fontstruct, " ");
	int win_width = (strlen(tmp) * char_width) + (WLISTPADDING * 2);		
	int win_height = th;
	int win_x, win_y;
	switch(WLISTPOS)
		{
			case 0:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
			case 1:
				win_x = SCREEN_WIDTH - PADDING_EAST - win_width - (BORDER * 2);
				win_y = PADDING_NORTH;
				break;
			case 2:
				win_x = 0 + SCREEN_WIDTH - PADDING_EAST - win_width;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 3:
				win_x = PADDING_WEST;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 4:
				win_x = (SCREEN_WIDTH / 2) - (win_width / 2);
				win_y = (SCREEN_HEIGHT / 2) - (win_height / 2);
				break;
			default:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
		}
	Window message_window = XCreateSimpleWindow(display, root, win_x,  win_y, win_width, win_height, BORDER, name2color(FGCOLOR), name2color(BGCOLOR));
	XSetWindowBorderWidth(display, message_window, BORDER);		
	XSetWindowBorder(display, message_window, name2color(SELBGCOLOR));		
	XMapRaised(display, message_window);
	XDrawString(display, message_window, BARE_GC, WLISTPADDING, 0 + th - fontstruct->max_bounds.descent, tmp, strlen(tmp));
	XFlush(display);
	sleep(TIMEOUT);
	XFlush(display);
	if(message_window)
	{
		XDestroyWindow(display, message_window);
	}
}
Beispiel #16
0
int MissionDescription(int y, const char *description, int hilite)
{
	int w_ws, w_word, x, lines;
	const char *ws, *word, *p, *s;

	TextGoto(20 - TextCharWidth('\020'), y);
	if (hilite)
		TextCharWithTable('\020', tableFlamed);
	else
		TextChar('\020');

	x = 20;
	lines = 1;
	TextGoto(x, y);

	s = ws = word = description;
	while (*s) {
		// Find word
		ws = s;
		while (*s == ' ' || *s == '\n')
			s++;
		word = s;
		while (*s != 0 && *s != ' ' && *s != '\n')
			s++;

		for (w_ws = 0, p = ws; p < word; p++)
			w_ws += TextCharWidth(*p);
		for (w_word = 0; p < s; p++)
			w_word += TextCharWidth(*p);

		if (x + w_ws + w_word > 300 && w_ws + w_word < 280) {
			y += TextHeight();
			x = 20;
			lines++;
			ws = word;
			w_ws = 0;
		}

		x += w_ws;
		TextGoto(x, y);

		for (p = word; p < s; p++)
			TextChar(*p);

		x += w_word;
	}

	if (hilite)
		TextCharWithTable('\021', tableFlamed);
	else
		TextChar('\021');

	return lines;
}
Beispiel #17
0
/*--------------------------------------------------------------------------*/
PegGroup::PegGroup(PegRect &Rect, const PEGCHAR *Text, WORD wFlags) :
    PegThing(Rect, 0, wFlags),
    PegTextThing(Text, wFlags & TT_COPY, PEG_GROUP_FONT)
{
    Type(TYPE_GROUP);
    AddStatus(PSF_TAB_STOP);
    mClient = mReal;
    mClient -= 2;
    mClient.wTop += TextHeight(lsTEST, mpFont) / 2;
    muColors[PCI_NTEXT] = PCLR_NORMAL_TEXT;
}
Beispiel #18
0
static void DisplaySummary()
{
	int i, y, x, x2;
	char sScore[20];
	unsigned char *scr = GetDstScreen();
	unsigned char color;

	y = SCREEN_HEIGHT - 5 - TextHeight(); // 10 pixels from bottom

	for (i = 0; i < gMission.missionData->objectiveCount; i++) {
		if (gMission.objectives[i].required > 0 ||
		    gMission.objectives[i].done > 0) {
			// Objective color dot
			color = gMission.objectives[i].color;

			x = 5;
			Draw_Rect(x, (y + 3), 2, 2, color);

			x += 5;
			x2 = x + TextWidth(gMission.missionData->objectives[i].description) + 5;

			sprintf(sScore, "(%d)", gMission.objectives[i].done);

			if (gMission.objectives[i].required <= 0) {
				TextStringWithTableAt(x, y,
						      gMission.missionData->objectives[i].description,
						      &tablePurple);
				TextStringWithTableAt(x2, y, sScore, &tablePurple);
			} else if (gMission.objectives[i].done >= gMission.objectives[i].required) {
				TextStringWithTableAt(x, y,
						      gMission.missionData->objectives[i].description,
						      &tableFlamed);
				TextStringWithTableAt(x2, y, sScore, &tableFlamed);
			} else {
				TextStringAt(x, y, gMission.missionData->objectives[i].description);
				TextStringAt(x2, y, sScore);
			}
			y -= (TextHeight() + 1);
		}
	}
}
Beispiel #19
0
static int BodyPartSelection(int x, int index, struct PlayerData *data,
			     int cmd, int *property, int *selection)
{
	int i;
	int y;

	if (cmd & (CMD_BUTTON1 | CMD_BUTTON2)) {
		PlaySound(SND_POWERGUN, 0, 255);
		return 0;
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (*selection > 0) {
			(*selection)--;
			*property = IndexToShade(*selection);
			PlaySound(SND_SWITCH, 0, 255);
		} else if (*selection == 0) {
			(*selection) = PLAYER_BODY_COUNT - 1;
			*property = IndexToShade(*selection);
			PlaySound(SND_SWITCH, 0, 255);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (*selection < PLAYER_BODY_COUNT - 1) {
			(*selection)++;
			*property = IndexToShade(*selection);
			PlaySound(SND_SWITCH, 0, 255);
		} else if (*selection == PLAYER_BODY_COUNT - 1) {
			(*selection) = 0;
			*property = IndexToShade(*selection);
			PlaySound(SND_SWITCH, 0, 255);
		}
	}

	y = CenterY((PLAYER_BODY_COUNT * TextHeight()));

	SetPlayer(index, data);
	for (i = 0; i < PLAYER_BODY_COUNT; i++)
		DisplayMenuItem(x, y + i * TextHeight(), shadeNames[i],
				i == *selection);

	return 1;
}
Beispiel #20
0
static void MissionStatus(void)
{
	//unsigned char *scr = GetDstScreen();
	unsigned char color;
	int i, left;
	char s[4];
	int allDone = 1;
	static int completed = 0;
	int x, y;

	if (gCampaign.dogFight)
		return;

	x = 5;
	y = SCREEN_HEIGHT - 5 - TextHeight();
	for (i = 0; i < gMission.missionData->objectiveCount; i++) {
		if (gMission.missionData->objectives[i].type ==
		    OBJECTIVE_INVESTIGATE)
			gMission.objectives[i].done = ExploredPercentage();

		if (gMission.missionData->objectives[i].required > 0) {
			// Objective color dot
			color = gMission.objectives[i].color;

			y += 3;
			Draw_Rect(x, y, 2, 2, color);
			y -= 3;

			left = gMission.objectives[i].required - gMission.objectives[i].done;

			if (left > 0) {
				if ((gMission.missionData->objectives[i].flags & OBJECTIVE_UNKNOWNCOUNT) == 0) {
					sprintf(s, "%d", left);
				} else {
					strcpy(s, "?");
				}
				TextStringAt(x + 5, y, s);
				allDone = 0;
			} else {
				TextStringAt(x + 5, y, "Done");
			}
			x += 30;
		}
	}

	if (allDone && !completed) {
		completed = 1;
		MarkExit();
	} else if (!allDone) {
		completed = 0;
	}
}
Beispiel #21
0
static void ShowSelection(int x, struct PlayerData *data, int character)
{
	int i;

	DisplayPlayer(x, data, character, 0);

	if (data->weaponCount == 0) {
			TextStringAt(x + 40, (SCREEN_HEIGHT / 10) + 20, "None selected...");
	} else {
		for (i = 0; i < data->weaponCount; i++)
			TextStringAt(x + 40, (SCREEN_HEIGHT / 10) + 20 + i * TextHeight(),
				     gunDesc[data->weapons[i]].gunName);
	}
}
Beispiel #22
0
double Legend::Width(std::vector<std::string> const& entries) const
{
    INFO(entries.size());
    TLatex longest(0, 0, boost::range::max_element(entries, [](std::string const & entry_1, std::string const & entry_2) {
        TLatex latex_1(0, 0, entry_1.c_str());
        SetText(latex_1);
        TLatex latex_2(0, 0, entry_2.c_str());
        SetText(latex_2);
        return latex_1.GetXsize() < latex_2.GetXsize();
    })->c_str());
    auto extra_width = 0.5 * TextHeight();
    auto width = longest.GetXsize() + RepresentationWidth() + extra_width;
    return width * columns_;  // TODO must be more sofisticated
}
Beispiel #23
0
	void OnHotSpotClick(wxScintillaEvent &event) {
		AutoCompCancel();
		CallTipCancel();

		wxPoint clientPos = PointFromPosition(event.GetPosition());
		wxPoint screenPos = ClientToScreen(clientPos);
		int lineHeight = TextHeight(LineFromPosition(event.GetPosition()));

		CloseWatch();
		m_watch = new OneVariableWatchView(
			this, event.GetText(),
			wxPoint(screenPos.x - 50, screenPos.y + lineHeight), 
			wxSize(100, 400));
		m_watch->Show();
	}
Beispiel #24
0
void WrappingTextView::ResetTextRect()
{
	BRect bounds = Bounds();
	BRect textRect = bounds;
	textRect.left = 4.0;
	textRect.top = m_vertical_offset + 4.0f;
	if (m_fixed_width)
		textRect.right = 8.0f + StringWidth( "0") * float(m_fixed_width);
	else
		textRect.right -= 4.0f;
	textRect.bottom -= 4.0f;
	SetTextRect(textRect);
	// we have to readjust the scrollbar-proportion, since
	// the BTextView doesn't do it correctly when we have
	// fooled in a vertical_offset:
	float small, big;
	BScrollBar* bar = ScrollBar( B_VERTICAL);
	if (!bar) 	return;
	bar->GetSteps( &small, &big);
	float height = TextHeight( 0, TextLength());
	if (height+m_vertical_offset)
		bar->SetProportion( MIN( 1.0f, big/(height+m_vertical_offset)));
	else 
		bar->SetProportion( 1.0f);

	if (BeamOnDano) {
		// circumvent a special feature/bug in Zeta with respect to 
		// the scrollbar not always calling ValueChanged() on a click.
		// Seemingly, changing the value twice hides the bug:
		bar->SetValue(1);
		bar->SetValue(0);
	}

	bar = ScrollBar( B_HORIZONTAL);
	if (!bar) 	return;
	float width = bounds.Width();
	float maxWidth = MAX( width, textRect.right);
	int numChildren = IsEditable() ? 0 : CountChildren();
	for( int i=0; i<numChildren; ++i) {
		float w = ChildAt( i)->Frame().Width();
		if (w > maxWidth)
			maxWidth = w;
	}
	bar->SetSteps( width/10, width);
	bar->SetRange( 0, MAX(0, maxWidth-width));
	bar->SetProportion( MIN( 1.0f, width/maxWidth));
}
Beispiel #25
0
static void ShowCredits(void)
{
	static int creditIndex = 0;
	static int lastTick = 0;
	int t;

	TextStringWithTableAt(16, SCREEN_HEIGHT - 50, "Credits:", &tableDarker);
	TextStringWithTableAt(20, SCREEN_HEIGHT - 40, credits[creditIndex].name, &tablePurple);
	TextStringWithTableAt(20, SCREEN_HEIGHT - 40 + TextHeight(), credits[creditIndex].message, &tableDarker);

	t = clock() / CLOCKS_PER_SEC;

	if (t > lastTick + CREDIT_PERIOD) {
		creditIndex++;
		if (creditIndex >= sizeof(credits) / sizeof(credits[0]))
			creditIndex = 0;
		lastTick = t;
	}
}
Beispiel #26
0
/*--------------------------------------------------------------------------*/
void PegTextBox::SetFont(PegFont *Font)
{
    PegTextThing::SetFont(Font);
    miLineHeight = TextHeight(lsTEST, mpFont);
    UpdateLineStarts();

    if (muScrollMode & WSM_AUTOSCROLL)
    {
        if (CheckAutoScroll())
        {
            UpdateLineStarts();
        }
    }

    if (StatusIs(PSF_VISIBLE))
    {
        Invalidate();
    }
}
Beispiel #27
0
static int DisplayPage(const char *title, int index, struct Entry *e,
		       int hilite1, int hilite2)
{
	int x = 80;
	int y = 5;

	TextStringAt(5, 5, title);
	while (index < MAX_ENTRY && e[index].score > 0 && x < 300) {
		y += DisplayEntry(x, y, index, &e[index], index == hilite1
				  || index == hilite2);
		if (y > 198 - TextHeight()) {
			y = 20;
			x += 100;
		}
		index++;
	}
	CopyToScreen();
	return index;
}
Beispiel #28
0
/*--------------------------------------------------------------------------*/
PegTextButton::PegTextButton(SIGNED iLeft, SIGNED iTop, SIGNED iWidth, 
    const PEGCHAR *Text, WORD wId, WORD wStyle) : PegButton(wId, wStyle),
    PegTextThing(Text, wStyle & TT_COPY, PEG_TBUTTON_FONT)
{
    Type(TYPE_TEXTBUTTON);

    mReal.wLeft = iLeft;
    mReal.wTop = iTop;
    mReal.wRight = mReal.wLeft + iWidth - 1;

    if (Text)
    {
        mReal.wBottom = mReal.wTop + TextHeight(Text, mpFont) + TBUTTON_PADDING;
    }
    else
    {
        mReal.wBottom = mReal.wTop + TBUTTON_PADDING;
    }
    mClient = mReal;
}
Beispiel #29
0
static void DisplayKeys(int x, int x2, int y, char *title,
			struct PlayerData *data, int index, int change)
{
	int i;

	TextStringAt(x, y, title);
	TextStringAt(x, y + TextHeight(), "Left");
	TextStringAt(x, y + 2 * TextHeight(), "Right");
	TextStringAt(x, y + 3 * TextHeight(), "Up");
	TextStringAt(x, y + 4 * TextHeight(), "Down");
	TextStringAt(x, y + 5 * TextHeight(), "Fire");
	TextStringAt(x, y + 6 * TextHeight(), "Switch/slide");

	for (i = 0; i < 6; i++)
		if (change == i)
			DisplayMenuItem(x2, y + (i + 1) * TextHeight(),
					SELECTKEY, index == i);
		else
			DisplayMenuItem(x2, y + (i + 1) * TextHeight(),
					SDL_GetKeyName(data->keys[i]),
					index == i);
}
Beispiel #30
0
void TextStringSpecial(const char *s, unsigned int opts, unsigned int xpad, unsigned int ypad)
{
    int scrw = SCREEN_WIDTH;
    int scrh = SCREEN_HEIGHT;
    int x, y, w, h;

    x = y = w = h = 0;
    w = TextWidth(s);
    h = TextHeight();

    if (FLAG_SET(opts, TEXT_XCENTER))	{
        x = (scrw - w) / 2;
    }
    if (FLAG_SET(opts, TEXT_YCENTER))	{
        y = (scrh - h) / 2;
    }

    if (FLAG_SET(opts, TEXT_LEFT))		{
        x = 0 + xpad;
    }
    if (FLAG_SET(opts, TEXT_RIGHT))		{
        x = scrw - w - xpad;
    }

    if (FLAG_SET(opts, TEXT_TOP))		{
        y = 0 + ypad;
    }
    if (FLAG_SET(opts, TEXT_BOTTOM))	{
        y = scrh - h - ypad;
    }

    if (FLAG_SET(opts, TEXT_FLAMED)) {
        TextStringWithTableAt(x, y, s, &tableFlamed);
    } else if (FLAG_SET(opts, TEXT_PURPLE)) {
        TextStringWithTableAt(x, y, s, &tablePurple);
    } else {
        TextStringAt(x, y, s);
    }
}