Files @ r23482:de566f8c088d
Branch filter:

Location: cpp/openttd-patchpack/source/src/texteff.cpp - annotation

Patric Stout
Remove: DOS support

In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.

Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.

Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.

By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.

Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
r5584:545d748cc681
r5584:545d748cc681
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r9111:983de9c5a848
r6422:5983361e241a
r5584:545d748cc681
r6998:9587370cd6e8
r7849:cfd99cb69695
r8114:866ed489ed98
r14078:b9c563f3b6ef
r8225:491804378826
r8270:c2ec53375c9d
r23128:57a1ceae9616
r5584:545d748cc681
r21383:942c32fb8b0e
r21383:942c32fb8b0e
r14049:815b288b8078
r14503:957285aedfbf
r14079:4360508cef5f
r20053:1f0b373e9dce
r14049:815b288b8078
r14079:4360508cef5f
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r6248:b940b09d7ab8
r5584:545d748cc681
r14078:b9c563f3b6ef
r5584:545d748cc681
r7545:2cbf405181b3
r14079:4360508cef5f
r5584:545d748cc681
r6998:9587370cd6e8
r5584:545d748cc681
r14078:b9c563f3b6ef
r14078:b9c563f3b6ef
r14078:b9c563f3b6ef
r5584:545d748cc681
r14078:b9c563f3b6ef
r5584:545d748cc681
r14078:b9c563f3b6ef
r6998:9587370cd6e8
r6998:9587370cd6e8
r5584:545d748cc681
r5584:545d748cc681
r5584:545d748cc681
r20053:1f0b373e9dce
r6998:9587370cd6e8
r5584:545d748cc681
r14049:815b288b8078
r14049:815b288b8078
r14049:815b288b8078
r6998:9587370cd6e8
r6998:9587370cd6e8
r6998:9587370cd6e8
r6998:9587370cd6e8
r6998:9587370cd6e8
r6998:9587370cd6e8
r6998:9587370cd6e8
r14078:b9c563f3b6ef
r19178:0d171bdb01e5
r6998:9587370cd6e8
r6998:9587370cd6e8
r20053:1f0b373e9dce
r6998:9587370cd6e8
r14049:815b288b8078
r6998:9587370cd6e8
r6998:9587370cd6e8
r6998:9587370cd6e8
r6998:9587370cd6e8
r14078:b9c563f3b6ef
r5584:545d748cc681
r5584:545d748cc681
r23127:a13182a294c6
r5584:545d748cc681
r23128:57a1ceae9616
r23128:57a1ceae9616
r23127:a13182a294c6
r23127:a13182a294c6
r14078:b9c563f3b6ef
r14078:b9c563f3b6ef
r14079:4360508cef5f
r14079:4360508cef5f
r14079:4360508cef5f
r23127:a13182a294c6
r14079:4360508cef5f
r14079:4360508cef5f
r14079:4360508cef5f
r14079:4360508cef5f
r19180:f1705a610ae7
r23127:a13182a294c6
r23127:a13182a294c6
r19180:f1705a610ae7
r5584:545d748cc681
r5584:545d748cc681
r5584:545d748cc681
r6247:96e840dbefcc
r5584:545d748cc681
r14078:b9c563f3b6ef
r5584:545d748cc681
r5584:545d748cc681
r5584:545d748cc681
r5584:545d748cc681
r14049:815b288b8078
r18462:a1ba75a7f741
r5584:545d748cc681
r14078:b9c563f3b6ef
r14078:b9c563f3b6ef
r14049:815b288b8078
r14049:815b288b8078
r22084:e2a53153637c
r14049:815b288b8078
r5584:545d748cc681
r5584:545d748cc681
/* $Id$ */

/*
 * This file is part of OpenTTD.
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 */

/** @file texteff.cpp Handling of text effects. */

#include "stdafx.h"
#include "texteff.hpp"
#include "transparency.h"
#include "strings_func.h"
#include "core/smallvec_type.hpp"
#include "viewport_func.h"
#include "settings_type.h"
#include "guitimer_func.h"

#include "safeguards.h"

/** Container for all information about a text effect */
struct TextEffect : public ViewportSign {
	uint64 params_1;     ///< DParam parameter
	uint64 params_2;     ///< second DParam parameter
	StringID string_id;  ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid
	uint8 duration;      ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING)
	TextEffectMode mode; ///< Type of text effect

	/** Reset the text effect */
	void Reset()
	{
		this->MarkDirty();
		this->width_normal = 0;
		this->string_id = INVALID_STRING_ID;
	}
};

static SmallVector<struct TextEffect, 32> _text_effects; ///< Text effects are stored there

/* Text Effects */
TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode)
{
	if (_game_mode == GM_MENU) return INVALID_TE_ID;

	TextEffectID i;
	for (i = 0; i < _text_effects.Length(); i++) {
		if (_text_effects[i].string_id == INVALID_STRING_ID) break;
	}
	if (i == _text_effects.Length()) _text_effects.Append();

	TextEffect *te = _text_effects.Get(i);

	/* Start defining this object */
	te->string_id = msg;
	te->duration = duration;
	te->params_1 = GetDParam(0);
	te->params_2 = GetDParam(1);
	te->mode = mode;

	/* Make sure we only dirty the new area */
	te->width_normal = 0;
	te->UpdatePosition(center, y, msg);

	return i;
}

void UpdateTextEffect(TextEffectID te_id, StringID msg)
{
	/* Update details */
	TextEffect *te = _text_effects.Get(te_id);
	if (msg == te->string_id && GetDParam(0) == te->params_1) return;
	te->string_id = msg;
	te->params_1 = GetDParam(0);
	te->params_2 = GetDParam(1);

	te->UpdatePosition(te->center, te->top, msg);
}

void RemoveTextEffect(TextEffectID te_id)
{
	_text_effects[te_id].Reset();
}

void MoveAllTextEffects(uint delta_ms)
{
	static GUITimer texteffecttimer = GUITimer(MILLISECONDS_PER_TICK);
	uint count = texteffecttimer.CountElapsed(delta_ms);
	if (count == 0) return;

	const TextEffect *end = _text_effects.End();
	for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
		if (te->string_id == INVALID_STRING_ID) continue;
		if (te->mode != TE_RISING) continue;

		if (te->duration < count) {
			te->Reset();
			continue;
		}

		te->MarkDirty(ZOOM_LVL_OUT_8X);
		te->duration -= count;
		te->top -= count * ZOOM_LVL_BASE;
		te->MarkDirty(ZOOM_LVL_OUT_8X);
	}
}

void InitTextEffects()
{
	_text_effects.Reset();
}

void DrawTextEffects(DrawPixelInfo *dpi)
{
	/* Don't draw the text effects when zoomed out a lot */
	if (dpi->zoom > ZOOM_LVL_OUT_8X) return;

	const TextEffect *end = _text_effects.End();
	for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
		if (te->string_id == INVALID_STRING_ID) continue;
		if (te->mode == TE_RISING || (_settings_client.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) {
			ViewportAddString(dpi, ZOOM_LVL_OUT_8X, te, te->string_id, te->string_id - 1, STR_NULL, te->params_1, te->params_2);
		}
	}
}