|
|
@ -60,12 +60,6 @@ static NewsID _current_news = INVALID_NEWS; ///< points to news item that should
|
|
|
|
static NewsID _oldest_news = 0; ///< points to first item in fifo queue
|
|
|
|
static NewsID _oldest_news = 0; ///< points to first item in fifo queue
|
|
|
|
static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo queue
|
|
|
|
static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo queue
|
|
|
|
|
|
|
|
|
|
|
|
struct news_d {
|
|
|
|
|
|
|
|
uint16 chat_height;
|
|
|
|
|
|
|
|
NewsItem *ni;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Forced news item.
|
|
|
|
/** Forced news item.
|
|
|
|
* Users can force an item by accessing the history or "last message".
|
|
|
|
* Users can force an item by accessing the history or "last message".
|
|
|
|
* If the message being shown was forced by the user, its index is stored in
|
|
|
|
* If the message being shown was forced by the user, its index is stored in
|
|
|
@ -73,10 +67,12 @@ assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
|
|
|
|
static NewsID _forced_news = INVALID_NEWS;
|
|
|
|
static NewsID _forced_news = INVALID_NEWS;
|
|
|
|
|
|
|
|
|
|
|
|
static uint _total_news = 0; ///< Number of news items in FIFO queue @see _news_items
|
|
|
|
static uint _total_news = 0; ///< Number of news items in FIFO queue @see _news_items
|
|
|
|
|
|
|
|
static void MoveToNextItem();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef void DrawNewsCallbackProc(struct Window *w, const NewsItem *ni);
|
|
|
|
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni);
|
|
|
|
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni);
|
|
|
|
void DrawNewsBankrupcy(Window *w, const NewsItem *ni);
|
|
|
|
void DrawNewsBankrupcy(Window *w, const NewsItem *ni);
|
|
|
|
static void MoveToNextItem();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static DrawNewsCallbackProc * const _draw_news_callback[] = {
|
|
|
|
static DrawNewsCallbackProc * const _draw_news_callback[] = {
|
|
|
|
DrawNewsNewVehicleAvail, ///< DNC_VEHICLEAVAIL
|
|
|
|
DrawNewsNewVehicleAvail, ///< DNC_VEHICLEAVAIL
|
|
|
@ -131,149 +127,154 @@ void InitNewsItemStructs()
|
|
|
|
_total_news = 0;
|
|
|
|
_total_news = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DrawNewsBorder(const Window *w)
|
|
|
|
struct NewsWindow : Window {
|
|
|
|
{
|
|
|
|
uint16 chat_height;
|
|
|
|
int left = 0;
|
|
|
|
NewsItem *ni;
|
|
|
|
int right = w->width - 1;
|
|
|
|
|
|
|
|
int top = 0;
|
|
|
|
|
|
|
|
int bottom = w->height - 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GfxFillRect(left, top, right, bottom, 0xF);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GfxFillRect(left, top, left, bottom, 0xD7);
|
|
|
|
NewsWindow(const WindowDesc *desc, NewsItem *ni) : Window(desc), ni(ni)
|
|
|
|
GfxFillRect(right, top, right, bottom, 0xD7);
|
|
|
|
{
|
|
|
|
GfxFillRect(left, top, right, top, 0xD7);
|
|
|
|
const Window *w = FindWindowById(WC_SEND_NETWORK_MSG, 0);
|
|
|
|
GfxFillRect(left, bottom, right, bottom, 0xD7);
|
|
|
|
this->chat_height = (w != NULL) ? w->height : 0;
|
|
|
|
|
|
|
|
|
|
|
|
DrawString(left + 2, top + 1, STR_00C6, TC_FROMSTRING);
|
|
|
|
this->ni = &_news_items[_forced_news == INVALID_NEWS ? _current_news : _forced_news];
|
|
|
|
}
|
|
|
|
this->flags4 |= WF_DISABLE_VP_SCROLL;
|
|
|
|
|
|
|
|
|
|
|
|
static void NewsWindowProc(Window *w, WindowEvent *e)
|
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
switch (e->event) {
|
|
|
|
|
|
|
|
case WE_CREATE: { // If chatbar is open at creation time, we need to go above it
|
|
|
|
|
|
|
|
const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0);
|
|
|
|
|
|
|
|
WP(w, news_d).chat_height = (w1 != NULL) ? w1->height : 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case WE_PAINT: {
|
|
|
|
void DrawNewsBorder()
|
|
|
|
const NewsItem *ni = WP(w, news_d).ni;
|
|
|
|
{
|
|
|
|
const NewsMode display_mode = _news_subtype_data[ni->subtype].display_mode;
|
|
|
|
int left = 0;
|
|
|
|
|
|
|
|
int right = this->width - 1;
|
|
|
|
|
|
|
|
int top = 0;
|
|
|
|
|
|
|
|
int bottom = this->height - 1;
|
|
|
|
|
|
|
|
|
|
|
|
switch (display_mode) {
|
|
|
|
GfxFillRect(left, top, right, bottom, 0xF);
|
|
|
|
case NM_NORMAL:
|
|
|
|
|
|
|
|
case NM_THIN: {
|
|
|
|
|
|
|
|
DrawNewsBorder(w);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DrawString(2, 1, STR_00C6, TC_FROMSTRING);
|
|
|
|
GfxFillRect(left, top, left, bottom, 0xD7);
|
|
|
|
|
|
|
|
GfxFillRect(right, top, right, bottom, 0xD7);
|
|
|
|
|
|
|
|
GfxFillRect(left, top, right, top, 0xD7);
|
|
|
|
|
|
|
|
GfxFillRect(left, bottom, right, bottom, 0xD7);
|
|
|
|
|
|
|
|
|
|
|
|
SetDParam(0, ni->date);
|
|
|
|
DrawString(left + 2, top + 1, STR_00C6, TC_FROMSTRING);
|
|
|
|
DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(ni->flags & NF_VIEWPORT)) {
|
|
|
|
virtual void OnPaint()
|
|
|
|
CopyInDParam(0, ni->params, lengthof(ni->params));
|
|
|
|
{
|
|
|
|
DrawStringMultiCenter(215, display_mode == NM_NORMAL ? 76 : 56,
|
|
|
|
const NewsMode display_mode = _news_subtype_data[this->ni->subtype].display_mode;
|
|
|
|
ni->string_id, w->width - 4);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
switch (display_mode) {
|
|
|
|
/* Back up transparency options to draw news view */
|
|
|
|
case NM_NORMAL:
|
|
|
|
TransparencyOptionBits to_backup = _transparency_opt;
|
|
|
|
case NM_THIN: {
|
|
|
|
_transparency_opt = 0;
|
|
|
|
this->DrawNewsBorder();
|
|
|
|
DrawWindowViewport(w);
|
|
|
|
|
|
|
|
_transparency_opt = to_backup;
|
|
|
|
DrawString(2, 1, STR_00C6, TC_FROMSTRING);
|
|
|
|
|
|
|
|
|
|
|
|
/* Shade the viewport into gray, or color*/
|
|
|
|
SetDParam(0, this->ni->date);
|
|
|
|
ViewPort *vp = w->viewport;
|
|
|
|
DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING);
|
|
|
|
GfxFillRect(vp->left - w->left, vp->top - w->top,
|
|
|
|
|
|
|
|
vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1,
|
|
|
|
if (!(this->ni->flags & NF_VIEWPORT)) {
|
|
|
|
(ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE)
|
|
|
|
CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
|
|
|
|
);
|
|
|
|
DrawStringMultiCenter(215, display_mode == NM_NORMAL ? 76 : 56,
|
|
|
|
|
|
|
|
this->ni->string_id, this->width - 4);
|
|
|
|
CopyInDParam(0, ni->params, lengthof(ni->params));
|
|
|
|
} else {
|
|
|
|
DrawStringMultiCenter(w->width / 2, 20, ni->string_id, w->width - 4);
|
|
|
|
/* Back up transparency options to draw news view */
|
|
|
|
}
|
|
|
|
TransparencyOptionBits to_backup = _transparency_opt;
|
|
|
|
break;
|
|
|
|
_transparency_opt = 0;
|
|
|
|
|
|
|
|
DrawWindowViewport(this);
|
|
|
|
|
|
|
|
_transparency_opt = to_backup;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Shade the viewport into gray, or color*/
|
|
|
|
|
|
|
|
ViewPort *vp = this->viewport;
|
|
|
|
|
|
|
|
GfxFillRect(vp->left - this->left, vp->top - this->top,
|
|
|
|
|
|
|
|
vp->left - this->left + vp->width - 1, vp->top - this->top + vp->height - 1,
|
|
|
|
|
|
|
|
(this->ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
|
|
|
|
|
|
|
|
DrawStringMultiCenter(this->width / 2, 20, this->ni->string_id, this->width - 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case NM_CALLBACK:
|
|
|
|
case NM_CALLBACK:
|
|
|
|
_draw_news_callback[_news_subtype_data[ni->subtype].callback](w, ni);
|
|
|
|
this->DrawNewsBorder();
|
|
|
|
break;
|
|
|
|
_draw_news_callback[_news_subtype_data[this->ni->subtype].callback](this, ni);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
DrawWindowWidgets(this);
|
|
|
|
if (!(ni->flags & NF_VIEWPORT)) {
|
|
|
|
if (!(this->ni->flags & NF_VIEWPORT)) {
|
|
|
|
CopyInDParam(0, ni->params, lengthof(ni->params));
|
|
|
|
CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
|
|
|
|
DrawStringMultiCenter(140, 38, ni->string_id, 276);
|
|
|
|
DrawStringMultiCenter(140, 38, this->ni->string_id, 276);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
DrawWindowViewport(w);
|
|
|
|
DrawWindowViewport(this);
|
|
|
|
CopyInDParam(0, ni->params, lengthof(ni->params));
|
|
|
|
CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
|
|
|
|
DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4);
|
|
|
|
DrawStringMultiCenter(this->width / 2, this->height - 16, this->ni->string_id, this->width - 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_CLICK:
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
switch (e->we.click.widget) {
|
|
|
|
{
|
|
|
|
case 1: {
|
|
|
|
switch (widget) {
|
|
|
|
NewsItem *ni = WP(w, news_d).ni;
|
|
|
|
case 1:
|
|
|
|
delete w;
|
|
|
|
this->ni->duration = 0;
|
|
|
|
ni->duration = 0;
|
|
|
|
delete this;
|
|
|
|
_forced_news = INVALID_NEWS;
|
|
|
|
_forced_news = INVALID_NEWS;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0: {
|
|
|
|
case 0:
|
|
|
|
NewsItem *ni = WP(w, news_d).ni;
|
|
|
|
if (this->ni->flags & NF_VEHICLE) {
|
|
|
|
if (ni->flags & NF_VEHICLE) {
|
|
|
|
Vehicle *v = GetVehicle(this->ni->data_a);
|
|
|
|
Vehicle *v = GetVehicle(ni->data_a);
|
|
|
|
ScrollMainWindowTo(v->x_pos, v->y_pos);
|
|
|
|
ScrollMainWindowTo(v->x_pos, v->y_pos);
|
|
|
|
} else if (this->ni->flags & NF_TILE) {
|
|
|
|
} else if (ni->flags & NF_TILE) {
|
|
|
|
if (_ctrl_pressed) {
|
|
|
|
if (_ctrl_pressed) {
|
|
|
|
ShowExtraViewPortWindow(this->ni->data_a);
|
|
|
|
ShowExtraViewPortWindow(ni->data_a);
|
|
|
|
if (this->ni->flags & NF_TILE2) {
|
|
|
|
if (ni->flags & NF_TILE2) {
|
|
|
|
ShowExtraViewPortWindow(this->ni->data_b);
|
|
|
|
ShowExtraViewPortWindow(ni->data_b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (!ScrollMainWindowToTile(this->ni->data_a) && this->ni->flags & NF_TILE2) {
|
|
|
|
if (!ScrollMainWindowToTile(ni->data_a) && ni->flags & NF_TILE2) {
|
|
|
|
ScrollMainWindowToTile(this->ni->data_b);
|
|
|
|
ScrollMainWindowToTile(ni->data_b);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_KEYPRESS:
|
|
|
|
virtual bool OnKeyPress(uint16 key, uint16 keycode)
|
|
|
|
if (e->we.keypress.keycode == WKC_SPACE) {
|
|
|
|
{
|
|
|
|
/* Don't continue. */
|
|
|
|
if (keycode == WKC_SPACE) {
|
|
|
|
e->we.keypress.cont = false;
|
|
|
|
/* Don't continue. */
|
|
|
|
delete w;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_INVALIDATE_DATA: // The chatbar has notified us that is was either created or closed
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
WP(w, news_d).chat_height = e->we.invalidate.data;
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
/* The chatbar has notified us that is was either created or closed */
|
|
|
|
|
|
|
|
this->chat_height = data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels
|
|
|
|
virtual void OnTick()
|
|
|
|
int y = max(w->top - 4, _screen.height - w->height - 12 - WP(w, news_d).chat_height);
|
|
|
|
{
|
|
|
|
if (y == w->top) return;
|
|
|
|
/* Scroll up newsmessages from the bottom in steps of 4 pixels */
|
|
|
|
|
|
|
|
int y = max(this->top - 4, _screen.height - this->height - 12 - this->chat_height);
|
|
|
|
|
|
|
|
if (y == this->top) return;
|
|
|
|
|
|
|
|
|
|
|
|
if (w->viewport != NULL) {
|
|
|
|
if (this->viewport != NULL) this->viewport->top += y - this->top;
|
|
|
|
w->viewport->top += y - w->top;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int diff = Delta(w->top, y);
|
|
|
|
int diff = Delta(this->top, y);
|
|
|
|
w->top = y;
|
|
|
|
this->top = y;
|
|
|
|
|
|
|
|
|
|
|
|
SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
|
|
|
|
SetDirtyBlocks(this->left, this->top - diff, this->left + this->width, this->top + this->height);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return the correct index in the pseudo-fifo
|
|
|
|
* Return the correct index in the pseudo-fifo
|
|
|
@ -401,7 +402,7 @@ static WindowDesc _news_type13_desc = {
|
|
|
|
WC_NEWS_WINDOW, WC_NONE,
|
|
|
|
WC_NEWS_WINDOW, WC_NONE,
|
|
|
|
WDF_DEF_WIDGET,
|
|
|
|
WDF_DEF_WIDGET,
|
|
|
|
_news_type13_widgets,
|
|
|
|
_news_type13_widgets,
|
|
|
|
NewsWindowProc
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const Widget _news_type2_widgets[] = {
|
|
|
|
static const Widget _news_type2_widgets[] = {
|
|
|
@ -415,7 +416,7 @@ static WindowDesc _news_type2_desc = {
|
|
|
|
WC_NEWS_WINDOW, WC_NONE,
|
|
|
|
WC_NEWS_WINDOW, WC_NONE,
|
|
|
|
WDF_DEF_WIDGET,
|
|
|
|
WDF_DEF_WIDGET,
|
|
|
|
_news_type2_widgets,
|
|
|
|
_news_type2_widgets,
|
|
|
|
NewsWindowProc
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const Widget _news_type0_widgets[] = {
|
|
|
|
static const Widget _news_type0_widgets[] = {
|
|
|
@ -431,7 +432,7 @@ static WindowDesc _news_type0_desc = {
|
|
|
|
WC_NEWS_WINDOW, WC_NONE,
|
|
|
|
WC_NEWS_WINDOW, WC_NONE,
|
|
|
|
WDF_DEF_WIDGET,
|
|
|
|
WDF_DEF_WIDGET,
|
|
|
|
_news_type0_widgets,
|
|
|
|
_news_type0_widgets,
|
|
|
|
NewsWindowProc
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -450,7 +451,7 @@ static void ShowNewspaper(NewsItem *ni)
|
|
|
|
case NM_NORMAL:
|
|
|
|
case NM_NORMAL:
|
|
|
|
case NM_CALLBACK:
|
|
|
|
case NM_CALLBACK:
|
|
|
|
_news_type13_desc.top = top;
|
|
|
|
_news_type13_desc.top = top;
|
|
|
|
w = new Window(&_news_type13_desc);
|
|
|
|
w = new NewsWindow(&_news_type13_desc, ni);
|
|
|
|
if (ni->flags & NF_VIEWPORT) {
|
|
|
|
if (ni->flags & NF_VIEWPORT) {
|
|
|
|
InitializeWindowViewport(w, 2, 58, 426, 110,
|
|
|
|
InitializeWindowViewport(w, 2, 58, 426, 110,
|
|
|
|
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
|
|
|
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
|
|
@ -459,7 +460,7 @@ static void ShowNewspaper(NewsItem *ni)
|
|
|
|
|
|
|
|
|
|
|
|
case NM_THIN:
|
|
|
|
case NM_THIN:
|
|
|
|
_news_type2_desc.top = top;
|
|
|
|
_news_type2_desc.top = top;
|
|
|
|
w = new Window(&_news_type2_desc);
|
|
|
|
w = new NewsWindow(&_news_type2_desc, ni);
|
|
|
|
if (ni->flags & NF_VIEWPORT) {
|
|
|
|
if (ni->flags & NF_VIEWPORT) {
|
|
|
|
InitializeWindowViewport(w, 2, 58, 426, 70,
|
|
|
|
InitializeWindowViewport(w, 2, 58, 426, 70,
|
|
|
|
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
|
|
|
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
|
|
@ -468,7 +469,7 @@ static void ShowNewspaper(NewsItem *ni)
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
_news_type0_desc.top = top;
|
|
|
|
_news_type0_desc.top = top;
|
|
|
|
w = new Window(&_news_type0_desc);
|
|
|
|
w = new NewsWindow(&_news_type0_desc, ni);
|
|
|
|
if (ni->flags & NF_VIEWPORT) {
|
|
|
|
if (ni->flags & NF_VIEWPORT) {
|
|
|
|
InitializeWindowViewport(w, 3, 17, 274, 47,
|
|
|
|
InitializeWindowViewport(w, 3, 17, 274, 47,
|
|
|
|
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
|
|
|
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
|
|
@ -478,9 +479,6 @@ static void ShowNewspaper(NewsItem *ni)
|
|
|
|
|
|
|
|
|
|
|
|
/*DEBUG(misc, 0, " cur %3d, old %2d, lat %3d, for %3d, tot %2d",
|
|
|
|
/*DEBUG(misc, 0, " cur %3d, old %2d, lat %3d, for %3d, tot %2d",
|
|
|
|
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/
|
|
|
|
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/
|
|
|
|
|
|
|
|
|
|
|
|
WP(w, news_d).ni = &_news_items[_forced_news == INVALID_NEWS ? _current_news : _forced_news];
|
|
|
|
|
|
|
|
w->flags4 |= WF_DISABLE_VP_SCROLL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Show news item in the ticker */
|
|
|
|
/** Show news item in the ticker */
|
|
|
@ -983,8 +981,8 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
|
|
|
|
* We also need an update of the current, forced and visible (open window)
|
|
|
|
* We also need an update of the current, forced and visible (open window)
|
|
|
|
* news's as this shifting could change the items they were pointing to */
|
|
|
|
* news's as this shifting could change the items they were pointing to */
|
|
|
|
if (_total_news != 0) {
|
|
|
|
if (_total_news != 0) {
|
|
|
|
Window *w = FindWindowById(WC_NEWS_WINDOW, 0);
|
|
|
|
NewsWindow *w = dynamic_cast<NewsWindow*>(FindWindowById(WC_NEWS_WINDOW, 0));
|
|
|
|
NewsID visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS;
|
|
|
|
NewsID visible_news = (w != NULL) ? (NewsID)(w->ni - _news_items) : INVALID_NEWS;
|
|
|
|
|
|
|
|
|
|
|
|
for (NewsID i = n;; i = DecreaseIndex(i)) {
|
|
|
|
for (NewsID i = n;; i = DecreaseIndex(i)) {
|
|
|
|
_news_items[i] = _news_items[DecreaseIndex(i)];
|
|
|
|
_news_items[i] = _news_items[DecreaseIndex(i)];
|
|
|
@ -992,7 +990,7 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
|
|
|
|
if (i != _latest_news) {
|
|
|
|
if (i != _latest_news) {
|
|
|
|
if (i == _current_news) _current_news = IncreaseIndex(_current_news);
|
|
|
|
if (i == _current_news) _current_news = IncreaseIndex(_current_news);
|
|
|
|
if (i == _forced_news) _forced_news = IncreaseIndex(_forced_news);
|
|
|
|
if (i == _forced_news) _forced_news = IncreaseIndex(_forced_news);
|
|
|
|
if (i == visible_news) WP(w, news_d).ni = &_news_items[IncreaseIndex(visible_news)];
|
|
|
|
if (i == visible_news) w->ni = &_news_items[IncreaseIndex(visible_news)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (i == _oldest_news) break;
|
|
|
|
if (i == _oldest_news) break;
|
|
|
|