Import combined Enhanced viewport: zoom out, overlays & tooltips (r53_27127) patch
https://www.tt-forums.net/viewtopic.php?f=33&t=53394pull/3/head
parent
fd3388467f
commit
536a95dfd0
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
/* $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 plans.cpp Handling of plans. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "plans_base.h"
|
||||
#include "core/pool_func.hpp"
|
||||
|
||||
/** Initialize the plan-pool */
|
||||
PlanPool _plan_pool("Plan");
|
||||
INSTANTIATE_POOL_METHODS(Plan)
|
||||
|
||||
Plan *_current_plan = NULL;
|
||||
Plan *_new_plan = NULL;
|
@ -0,0 +1,237 @@
|
||||
/* $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 plans_base.h Base class for plans. */
|
||||
|
||||
#ifndef PLANS_BASE_H
|
||||
#define PLANS_BASE_H
|
||||
|
||||
#include "plans_func.h"
|
||||
#include "core/pool_type.hpp"
|
||||
#include "company_type.h"
|
||||
#include "company_func.h"
|
||||
#include "command_func.h"
|
||||
#include "map_func.h"
|
||||
#include "date_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "core/endian_func.hpp"
|
||||
#include <vector>
|
||||
|
||||
typedef Pool<Plan, PlanID, 16, 64000> PlanPool;
|
||||
typedef std::vector<TileIndex> TileVector;
|
||||
typedef std::vector<PlanLine*> PlanLineVector;
|
||||
extern PlanPool _plan_pool;
|
||||
|
||||
struct PlanLine {
|
||||
bool visible;
|
||||
bool focused;
|
||||
TileVector tiles;
|
||||
|
||||
PlanLine()
|
||||
{
|
||||
this->visible = true;
|
||||
this->focused = false;
|
||||
}
|
||||
|
||||
~PlanLine()
|
||||
{
|
||||
this->Clear();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
this->tiles.clear();
|
||||
}
|
||||
|
||||
bool AppendTile(TileIndex tile)
|
||||
{
|
||||
const uint cnt = (uint) this->tiles.size();
|
||||
|
||||
if (cnt > 0) {
|
||||
const TileIndex last_tile = this->tiles[cnt - 1];
|
||||
if (last_tile == tile) return false;
|
||||
MarkTileLineDirty(last_tile, tile);
|
||||
|
||||
if (cnt > 1) {
|
||||
const TileIndex t0 = this->tiles[cnt - 2];
|
||||
const int x0 = (int) TileX(t0);
|
||||
const int y0 = (int) TileY(t0);
|
||||
const TileIndex t1 = this->tiles[cnt - 1];
|
||||
const int x1 = (int) TileX(t1);
|
||||
const int y1 = (int) TileY(t1);
|
||||
const int x2 = (int) TileX(tile);
|
||||
const int y2 = (int) TileY(tile);
|
||||
|
||||
if ((y1 - y0) * (x2 - x1) == (y2 - y1) * (x1 - x0)) { // Same direction.
|
||||
if (abs(x2 - x1) <= abs(x2 - x0) && abs(y2 - y1) <= abs(y2 - y0)) { // Tile i+1 is between i and i+2.
|
||||
/* The new tile is in the continuity, just update the last tile. */
|
||||
this->tiles[cnt - 1] = tile;
|
||||
MarkTileLineDirty(t1, tile);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->tiles.size() * sizeof(TileIndex) >= MAX_CMD_TEXT_LENGTH) return false;
|
||||
|
||||
this->tiles.push_back(tile);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetFocus(bool focused)
|
||||
{
|
||||
if (this->focused != focused) this->MarkDirty();
|
||||
this->focused = focused;
|
||||
}
|
||||
|
||||
bool ToggleVisibility()
|
||||
{
|
||||
this->SetVisibility(!this->visible);
|
||||
return this->visible;
|
||||
}
|
||||
|
||||
void SetVisibility(bool visible)
|
||||
{
|
||||
if (this->visible != visible) this->MarkDirty();
|
||||
this->visible = visible;
|
||||
}
|
||||
|
||||
void MarkDirty()
|
||||
{
|
||||
const uint sz = (uint) this->tiles.size();
|
||||
for (uint i = 1; i < sz; i++) {
|
||||
MarkTileLineDirty(this->tiles[i-1], this->tiles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TileIndex *Export(uint *buffer_length)
|
||||
{
|
||||
const uint cnt = (uint) this->tiles.size();
|
||||
const uint datalen = sizeof(TileIndex) * cnt;
|
||||
TileIndex *buffer = (TileIndex *) malloc(datalen);
|
||||
if (buffer) {
|
||||
for (uint i = 0; i < cnt; i++) {
|
||||
buffer[i] = TO_LE32(this->tiles[i]);
|
||||
}
|
||||
if (buffer_length) *buffer_length = datalen;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void Import(const TileIndex* data, const uint data_length)
|
||||
{
|
||||
for (uint i = data_length; i != 0; i--, data++) {
|
||||
this->tiles.push_back(FROM_LE32(*data));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct Plan : PlanPool::PoolItem<&_plan_pool> {
|
||||
OwnerByte owner;
|
||||
PlanLineVector lines;
|
||||
PlanLine *temp_line;
|
||||
bool visible;
|
||||
bool visible_by_all;
|
||||
bool show_lines;
|
||||
Date creation_date;
|
||||
|
||||
Plan(Owner owner = INVALID_OWNER)
|
||||
{
|
||||
this->owner = owner;
|
||||
this->creation_date = _date;
|
||||
this->visible = false;
|
||||
this->visible_by_all = false;
|
||||
this->show_lines = false;
|
||||
this->temp_line = new PlanLine();
|
||||
}
|
||||
|
||||
~Plan()
|
||||
{
|
||||
for (PlanLineVector::iterator it = lines.begin(); it != lines.end(); it++) {
|
||||
delete (*it);
|
||||
}
|
||||
this->lines.clear();
|
||||
delete temp_line;
|
||||
}
|
||||
|
||||
void SetFocus(bool focused)
|
||||
{
|
||||
for (PlanLineVector::iterator it = lines.begin(); it != lines.end(); it++) {
|
||||
(*it)->SetFocus(focused);
|
||||
}
|
||||
}
|
||||
|
||||
void SetVisibility(bool visible, bool do_lines = true)
|
||||
{
|
||||
this->visible = visible;
|
||||
|
||||
if (!do_lines) return;
|
||||
for (PlanLineVector::iterator it = lines.begin(); it != lines.end(); it++) {
|
||||
(*it)->SetVisibility(visible);
|
||||
}
|
||||
}
|
||||
|
||||
bool ToggleVisibility()
|
||||
{
|
||||
this->SetVisibility(!this->visible);
|
||||
return this->visible;
|
||||
}
|
||||
|
||||
PlanLine *NewLine()
|
||||
{
|
||||
PlanLine *pl = new PlanLine();
|
||||
if (pl) this->lines.push_back(pl);
|
||||
return pl;
|
||||
}
|
||||
|
||||
bool StoreTempTile(TileIndex tile)
|
||||
{
|
||||
return this->temp_line->AppendTile(tile);
|
||||
}
|
||||
|
||||
bool ValidateNewLine()
|
||||
{
|
||||
bool ret = false;
|
||||
if (this->temp_line->tiles.size() > 1) {
|
||||
uint buffer_length = 0;
|
||||
const TileIndex *buffer = this->temp_line->Export(&buffer_length);
|
||||
if (buffer) {
|
||||
_current_plan->SetVisibility(true, false);
|
||||
ret = DoCommandP(0, _current_plan->index, (uint32) this->temp_line->tiles.size(), CMD_ADD_PLAN_LINE, NULL, (const char *) buffer, true, buffer_length);
|
||||
free(buffer);
|
||||
}
|
||||
_current_plan->temp_line->MarkDirty();
|
||||
this->temp_line->Clear();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool IsListable()
|
||||
{
|
||||
return (this->owner == _local_company || this->visible_by_all);
|
||||
}
|
||||
|
||||
bool IsVisible()
|
||||
{
|
||||
if (!this->IsListable()) return false;
|
||||
return this->visible;
|
||||
}
|
||||
|
||||
bool ToggleVisibilityByAll()
|
||||
{
|
||||
if (_current_plan->owner == _local_company) DoCommandP(0, _current_plan->index, !this->visible_by_all, CMD_CHANGE_PLAN_VISIBILITY);
|
||||
return this->visible_by_all;
|
||||
}
|
||||
};
|
||||
|
||||
#define FOR_ALL_PLANS_FROM(var, start) FOR_ALL_ITEMS_FROM(Plan, plan_index, var, start)
|
||||
#define FOR_ALL_PLANS(var) FOR_ALL_PLANS_FROM(var, 0)
|
||||
|
||||
#endif /* PLANS_BASE_H */
|
@ -0,0 +1,140 @@
|
||||
/* $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 plans_cmd.cpp Handling of plan related commands. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "command_func.h"
|
||||
#include "plans_base.h"
|
||||
#include "plans_func.h"
|
||||
#include "window_func.h"
|
||||
#include "company_func.h"
|
||||
#include "window_gui.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
/**
|
||||
* Create a new plan.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 owner of the plan
|
||||
* @param p2 unused
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdAddPlan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (!Plan::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_PLANS);
|
||||
if (flags & DC_EXEC) {
|
||||
Owner o = (Owner) p1;
|
||||
_new_plan = new Plan(o);
|
||||
if (o == _local_company) {
|
||||
_new_plan->SetVisibility(true);
|
||||
Window *w = FindWindowById(WC_PLANS, 0);
|
||||
if (w) w->InvalidateData(INVALID_PLAN, false);
|
||||
}
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new line in a plan.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 plan id
|
||||
* @param p2 number of nodes
|
||||
* @param text list of tile indexes that compose the line, encoded in base64
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdAddPlanLine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
Plan *p = Plan::Get(p1);
|
||||
PlanLine *pl = p->NewLine();
|
||||
if (!pl) return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_LINES);
|
||||
if (p2 > (MAX_CMD_TEXT_LENGTH / sizeof(TileIndex))) return_cmd_error(STR_ERROR_TOO_MANY_NODES);
|
||||
pl->Import((const TileIndex *) text, p2);
|
||||
if (p->IsListable()) {
|
||||
pl->SetVisibility(p->visible);
|
||||
if (p->visible) pl->MarkDirty();
|
||||
Window *w = FindWindowById(WC_PLANS, 0);
|
||||
if (w) w->InvalidateData(INVALID_PLAN, false);
|
||||
}
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the visibility of a plan.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 plan id
|
||||
* @param p2 visibility
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdChangePlanVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
Plan *p = Plan::Get(p1);
|
||||
p->visible_by_all = p2 != 0;
|
||||
Window *w = FindWindowById(WC_PLANS, 0);
|
||||
if (w) w->InvalidateData(INVALID_PLAN, false);
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a plan.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 plan id
|
||||
* @param p2 unused
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemovePlan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
Plan *p = Plan::Get(p1);
|
||||
if (p->IsListable()) {
|
||||
p->SetVisibility(false);
|
||||
Window *w = FindWindowById(WC_PLANS, 0);
|
||||
if (w) w->InvalidateData(p->index, false);
|
||||
}
|
||||
if (p == _current_plan) _current_plan = NULL;
|
||||
delete p;
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a line from a plan.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 plan id
|
||||
* @param p2 line id
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemovePlanLine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
Plan *p = Plan::Get(p1);
|
||||
PlanLineVector::iterator it = p->lines.begin();
|
||||
std::advance(it, p2);
|
||||
(*it)->SetVisibility(false);
|
||||
delete *it;
|
||||
p->lines.erase(it);
|
||||
if (p->IsListable()) {
|
||||
Window *w = FindWindowById(WC_PLANS, 0);
|
||||
if (w) w->InvalidateData(p->index, false);
|
||||
}
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/* $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 plans_func.h Functions related to plans. */
|
||||
|
||||
#ifndef PLANS_FUNC_H
|
||||
#define PLANS_FUNC_H
|
||||
|
||||
#include "plans_type.h"
|
||||
|
||||
void ShowPlansWindow();
|
||||
|
||||
extern Plan *_new_plan;
|
||||
extern Plan *_current_plan;
|
||||
|
||||
#endif /* PLANS_FUNC_H */
|
@ -0,0 +1,366 @@
|
||||
/* $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 plans_gui.cpp The GUI for planning. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "plans_func.h"
|
||||
#include "plans_base.h"
|
||||
#include "command_func.h"
|
||||
#include "company_func.h"
|
||||
#include "company_gui.h"
|
||||
#include "settings_gui.h"
|
||||
#include "window_gui.h"
|
||||
#include "window_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "gfx_func.h"
|
||||
#include "tilehighlight_func.h"
|
||||
#include "strings_func.h"
|
||||
#include "core/pool_func.hpp"
|
||||
#include "widgets/plans_widget.h"
|
||||
#include "table/strings.h"
|
||||
#include "table/sprites.h"
|
||||
|
||||
static const NWidgetPart _nested_plans_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_PLN_CAPTION), SetDataTip(STR_PLANS_CAPTION, STR_NULL),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_INSET, COLOUR_GREY, WID_PLN_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2), SetResize(1, 0), SetScrollbar(WID_PLN_SCROLLBAR), SetDataTip(STR_NULL, STR_PLANS_LIST_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_PLN_SCROLLBAR),
|
||||
EndContainer(),
|
||||
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_NEW), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_NEW_PLAN, STR_NULL),
|
||||
NWidget(WWT_TEXTBTN_2, COLOUR_GREY, WID_PLN_ADD_LINES), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_ADD_LINES, STR_PLANS_ADDING_LINES),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_PLN_VISIBILITY), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_VISIBILITY_PUBLIC, STR_PLANS_VISIBILITY_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_HIDE_ALL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_HIDE_ALL, STR_NULL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_DELETE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_DELETE, STR_PLANS_DELETE_TOOLTIP),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _plans_desc(
|
||||
WDP_AUTO, "plans", 300, 100,
|
||||
WC_PLANS, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_plans_widgets, lengthof(_nested_plans_widgets)
|
||||
);
|
||||
|
||||
struct PlansWindow : Window {
|
||||
typedef struct {
|
||||
bool is_plan;
|
||||
int plan_id;
|
||||
int line_id;
|
||||
} ListItem;
|
||||
|
||||
Scrollbar *vscroll;
|
||||
int text_offset;
|
||||
std::vector<ListItem> list; ///< The translation table linking panel indices to their related PlanID.
|
||||
int selected; ///< What item is currently selected in the panel.
|
||||
|
||||
PlansWindow(WindowDesc *desc) : Window(desc)
|
||||
{
|
||||
this->CreateNestedTree();
|
||||
this->vscroll = this->GetScrollbar(WID_PLN_SCROLLBAR);
|
||||
this->FinishInitNested();
|
||||
|
||||
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2 + SETTING_BUTTON_WIDTH;
|
||||
|
||||
this->selected = INT_MAX;
|
||||
RebuildList();
|
||||
}
|
||||
|
||||
~PlansWindow()
|
||||
{
|
||||
this->list.clear();
|
||||
_current_plan = NULL;
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_PLN_NEW:
|
||||
DoCommandP(0, _local_company, 0, CMD_ADD_PLAN, CcAddPlan);
|
||||
break;
|
||||
case WID_PLN_ADD_LINES:
|
||||
if (_current_plan) HandlePlacePushButton(this, widget, SPR_CURSOR_MOUSE, HT_POINT);
|
||||
break;
|
||||
case WID_PLN_DELETE:
|
||||
if (this->selected != INT_MAX) {
|
||||
if (this->list[this->selected].is_plan) {
|
||||
DoCommandP(0, this->list[this->selected].plan_id, 0, CMD_REMOVE_PLAN);
|
||||
} else {
|
||||
DoCommandP(0, this->list[this->selected].plan_id, this->list[this->selected].line_id, CMD_REMOVE_PLAN_LINE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WID_PLN_HIDE_ALL: {
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
if (p->IsListable()) p->SetVisibility(false);
|
||||
}
|
||||
this->SetWidgetDirty(WID_PLN_LIST);
|
||||
break;
|
||||
}
|
||||
case WID_PLN_VISIBILITY:
|
||||
if (_current_plan) _current_plan->ToggleVisibilityByAll();
|
||||
break;
|
||||
case WID_PLN_LIST: {
|
||||
int new_selected = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_PLN_LIST, WD_FRAMERECT_TOP);
|
||||
if (this->selected != INT_MAX) {
|
||||
_current_plan->SetFocus(false);
|
||||
}
|
||||
if (new_selected != INT_MAX) {
|
||||
if (this->list[new_selected].is_plan) {
|
||||
_current_plan = Plan::Get(this->list[new_selected].plan_id);
|
||||
_current_plan->SetFocus(true);
|
||||
if (pt.x >= 22 && pt.x < 41) _current_plan->ToggleVisibility();
|
||||
} else {
|
||||
_current_plan = Plan::Get(this->list[new_selected].plan_id);
|
||||
PlanLine *pl = _current_plan->lines[this->list[new_selected].line_id];
|
||||
pl->SetFocus(true);
|
||||
if (pt.x >= 22 && pt.x < 41) {
|
||||
if (pl->ToggleVisibility()) _current_plan->SetVisibility(true, false);
|
||||
}
|
||||
}
|
||||
if (click_count > 1 && (pt.x < 22 || pt.x >= 41)) {
|
||||
_current_plan->show_lines = !_current_plan->show_lines;
|
||||
this->InvalidateData(INVALID_PLAN);
|
||||
}
|
||||
} else {
|
||||
if (_current_plan) {
|
||||
_current_plan->SetFocus(false);
|
||||
_current_plan = NULL;
|
||||
}
|
||||
}
|
||||
this->selected = new_selected;
|
||||
this->SetDirty();
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
{
|
||||
this->SetWidgetDisabledState(WID_PLN_HIDE_ALL, this->vscroll->GetCount() == 0);
|
||||
if (_current_plan) {
|
||||
this->SetWidgetsDisabledState(_current_plan->owner != _local_company, WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_DELETE, WIDGET_LIST_END);
|
||||
this->GetWidget<NWidgetCore>(WID_PLN_VISIBILITY)->widget_data = _current_plan->visible_by_all ? STR_PLANS_VISIBILITY_PRIVATE : STR_PLANS_VISIBILITY_PUBLIC;
|
||||
} else {
|
||||
this->SetWidgetsDisabledState(true, WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_DELETE, WIDGET_LIST_END);
|
||||
}
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_PLN_LIST: {
|
||||
uint y = r.top + WD_FRAMERECT_TOP; // Offset from top of widget.
|
||||
if (this->vscroll->GetCount() == 0) {
|
||||
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_STATION_LIST_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
uint icon_left = 4 + (rtl ? r.right - this->text_offset : r.left);
|
||||
uint btn_left = (rtl ? icon_left - SETTING_BUTTON_WIDTH + 4 : icon_left + SETTING_BUTTON_WIDTH - 4);
|
||||
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : this->text_offset);
|
||||
uint text_right = r.right - (rtl ? this->text_offset : WD_FRAMERECT_RIGHT);
|
||||
|
||||
for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
|
||||
Plan *p = Plan::Get(list[i].plan_id);
|
||||
|
||||
if (i == this->selected) GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_DARK_GREY);
|
||||
|
||||
if (list[i].is_plan) {
|
||||
DrawCompanyIcon(p->owner, icon_left, y + (FONT_HEIGHT_NORMAL - 10) / 2 + 1);
|
||||
DrawBoolButton(btn_left, y + (FONT_HEIGHT_NORMAL - 10) / 2, p->visible, true);
|
||||
SetDParam(0, list[i].plan_id + 1);
|
||||
SetDParam(1, p->lines.size());
|
||||
SetDParam(2, p->creation_date);
|
||||
DrawString(text_left, text_right, y, STR_PLANS_LIST_ITEM_PLAN, p->visible_by_all ? TC_LIGHT_BLUE : TC_YELLOW);
|
||||
} else {
|
||||
PlanLine *pl = p->lines[list[i].line_id];
|
||||
DrawBoolButton(btn_left, y + (FONT_HEIGHT_NORMAL - 10) / 2, pl->visible, true);
|
||||
SetDParam(0, list[i].line_id + 1);
|
||||
SetDParam(1, pl->tiles.size() - 1);
|
||||
DrawString(text_left, text_right, y, STR_PLANS_LIST_ITEM_LINE, TC_WHITE);
|
||||
}
|
||||
y += this->resize.step_height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_PLN_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_PLN_LIST:
|
||||
resize->height = FONT_HEIGHT_NORMAL;
|
||||
size->height = resize->height * 5 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** The drawing of a line starts. */
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
{
|
||||
/* A player can't add lines to a public plan of another company. */
|
||||
if (_current_plan && _current_plan->owner == _local_company) VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DRAW_PLANLINE);
|
||||
}
|
||||
|
||||
/** The drawing of a line is in progress. */
|
||||
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
|
||||
{
|
||||
const Point p = GetTileBelowCursor();
|
||||
const TileIndex tile = TileVirtXY(p.x, p.y);
|
||||
if (_current_plan && tile < MapSize()) {
|
||||
_current_plan->StoreTempTile(tile);
|
||||
_thd.selstart = _thd.selend;
|
||||
}
|
||||
}
|
||||
|
||||
/** The drawing of a line ends up normally. */
|
||||
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
|
||||
{
|
||||
if (_current_plan) _current_plan->ValidateNewLine();
|
||||
}
|
||||
|
||||
/** The drawing of a line is aborted. */
|
||||
virtual void OnPlaceObjectAbort()
|
||||
{
|
||||
if (_current_plan) {
|
||||
_current_plan->temp_line->MarkDirty();
|
||||
_current_plan->temp_line->Clear();
|
||||
}
|
||||
|
||||
this->RaiseWidget(WID_PLN_ADD_LINES);
|
||||
this->SetWidgetDirty(WID_PLN_ADD_LINES);
|
||||
}
|
||||
|
||||
void RebuildList()
|
||||
{
|
||||
int old_focused_plan_id = this->selected == INT_MAX ? INT_MAX : this->list[this->selected].plan_id;
|
||||
|
||||
int sbcnt = 0;
|
||||
this->list.clear();
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
if (!p->IsListable()) continue;
|
||||
|
||||
ListItem li;
|
||||
li.is_plan = true;
|
||||
li.plan_id = p->index;
|
||||
this->list.push_back(li);
|
||||
if (old_focused_plan_id == p->index) this->selected = sbcnt;
|
||||
sbcnt++;
|
||||
|
||||
if (p->show_lines) {
|
||||
const int sz = (int) p->lines.size();
|
||||
sbcnt += sz;
|
||||
li.is_plan = false;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
li.line_id = i;
|
||||
this->list.push_back(li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->selected == INT_MAX) ResetObjectToPlace();
|
||||
|
||||
this->vscroll->SetCount(sbcnt);
|
||||
}
|
||||
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
{
|
||||
if (data != INVALID_PLAN && this->selected != INT_MAX) {
|
||||
if (this->list[this->selected].plan_id == data) {
|
||||
/* Invalidate the selection if the selected plan has been modified or deleted. */
|
||||
this->selected = INT_MAX;
|
||||
|
||||
/* Cancel drawing associated to the deleted plan. */
|
||||
ResetObjectToPlace();
|
||||
}
|
||||
}
|
||||
|
||||
RebuildList();
|
||||
}
|
||||
|
||||
void SelectPlan(PlanID plan_index)
|
||||
{
|
||||
if (this->selected != INT_MAX) {
|
||||
if (plan_index == this->list[this->selected].plan_id) return;
|
||||
Plan::Get(this->list[this->selected].plan_id)->SetFocus(false);
|
||||
}
|
||||
|
||||
if (plan_index == INVALID_PLAN) {
|
||||
this->selected = INT_MAX;
|
||||
return;
|
||||
}
|
||||
Plan::Get(plan_index)->SetFocus(true);
|
||||
|
||||
for (size_t i = 0; i < this->list.size(); i++) {
|
||||
if (this->list[i].is_plan && this->list[i].plan_id == plan_index) {
|
||||
this->selected = (int) i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** Show the window to manage plans. */
|
||||
void ShowPlansWindow()
|
||||
{
|
||||
if (BringWindowToFrontById(WC_PLANS, 0) != NULL) return;
|
||||
new PlansWindow(&_plans_desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the creator of a plan executes this function.
|
||||
* The other players should not be bothered with these changes.
|
||||
*/
|
||||
void CcAddPlan(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
_current_plan = _new_plan;
|
||||
_current_plan->SetVisibility(true);
|
||||
|
||||
Window *w = FindWindowById(WC_PLANS, 0);
|
||||
if (w) {
|
||||
w->InvalidateData(INVALID_PLAN, false);
|
||||
((PlansWindow *) w)->SelectPlan(_current_plan->index);
|
||||
if (!w->IsWidgetLowered(WID_PLN_ADD_LINES)) {
|
||||
w->SetWidgetDisabledState(WID_PLN_ADD_LINES, false);
|
||||
HandlePlacePushButton(w, WID_PLN_ADD_LINES, SPR_CURSOR_MOUSE, HT_POINT);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/* $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 plans_type.h Types related to planning. */
|
||||
|
||||
#ifndef PLANS_TYPE_H
|
||||
#define PLANS_TYPE_H
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/smallvec_type.hpp"
|
||||
#include "tile_type.h"
|
||||
|
||||
typedef uint16 PlanID;
|
||||
struct PlanLine;
|
||||
struct Plan;
|
||||
|
||||
static const PlanID INVALID_PLAN = 0xFFFF; ///< Sentinel for an invalid plan.
|
||||
|
||||
#endif /* PLANS_TYPE_H */
|
@ -0,0 +1,87 @@
|
||||
/* $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 plans_sl.cpp Code handling saving and loading of plans data. */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../plans_base.h"
|
||||
#include "../fios.h"
|
||||
|
||||
#include "saveload.h"
|
||||
|
||||
/** Description of a plan within the savegame. */
|
||||
static const SaveLoad _plan_desc[] = {
|
||||
SLE_VAR(Plan, owner, SLE_UINT8),
|
||||
SLE_VAR(Plan, visible, SLE_BOOL),
|
||||
SLE_VAR(Plan, visible_by_all, SLE_BOOL),
|
||||
SLE_VAR(Plan, creation_date, SLE_INT32),
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
/** Save all plans. */
|
||||
static void Save_PLAN()
|
||||
{
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
SlSetArrayIndex(p->index);
|
||||
SlObject(p, _plan_desc);
|
||||
}
|
||||
}
|
||||
|
||||
/** Load all plans. */
|
||||
static void Load_PLAN()
|
||||
{
|
||||
int index;
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
Plan *p = new (index) Plan();
|
||||
SlObject(p, _plan_desc);
|
||||
}
|
||||
}
|
||||
|
||||
/** Save all plan lines. */
|
||||
static void Save_PLANLINE()
|
||||
{
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
for (size_t i = 0; i < p->lines.size(); i++) {
|
||||
SlSetArrayIndex((uint) p->index << 16 | (uint) i);
|
||||
PlanLine *pl = p->lines[i];
|
||||
size_t plsz = pl->tiles.size();
|
||||
SlSetLength(plsz * sizeof(TileIndex));
|
||||
SlArray(&pl->tiles[0], plsz, SLE_UINT32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Load all plan lines. */
|
||||
static void Load_PLANLINE()
|
||||
{
|
||||
int index;
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
Plan *p = Plan::Get((uint) index >> 16);
|
||||
uint line_index = index & 0xFFFF;
|
||||
if (p->lines.size() <= line_index) p->lines.resize(line_index + 1);
|
||||
PlanLine *pl = new PlanLine();
|
||||
p->lines[line_index] = pl;
|
||||
size_t plsz = SlGetFieldLength() / sizeof(TileIndex);
|
||||
pl->tiles.resize(plsz);
|
||||
SlArray(&pl->tiles[0], plsz, SLE_UINT32);
|
||||
}
|
||||
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
p->SetVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Chunk handlers related to plans. */
|
||||
extern const ChunkHandler _plan_chunk_handlers[] = {
|
||||
{ 'PLAN', Save_PLAN, Load_PLAN, NULL, NULL, CH_ARRAY},
|
||||
{ 'PLLN', Save_PLANLINE, Load_PLANLINE, NULL, NULL, CH_ARRAY | CH_LAST},
|
||||
};
|
@ -0,0 +1,106 @@
|
||||
/* $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 smallmap_colours.h Colours used by smallmap. */
|
||||
|
||||
#ifndef SMALLMAP_COLOURS_H
|
||||
#define SMALLMAP_COLOURS_H
|
||||
|
||||
#include "core/endian_func.hpp"
|
||||
|
||||
static const uint8 PC_ROUGH_LAND = 0x52; ///< Dark green palette colour for rough land.
|
||||
static const uint8 PC_GRASS_LAND = 0x54; ///< Dark green palette colour for grass land.
|
||||
static const uint8 PC_BARE_LAND = 0x37; ///< Brown palette colour for bare land.
|
||||
static const uint8 PC_FIELDS = 0x25; ///< Light brown palette colour for fields.
|
||||
static const uint8 PC_TREES = 0x57; ///< Green palette colour for trees.
|
||||
static const uint8 PC_WATER = 0xCA; ///< Dark blue palette colour for water.
|
||||
|
||||
#define MKCOLOUR(x) TO_LE32X(x)
|
||||
|
||||
#define MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x))
|
||||
#define MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x))
|
||||
#define MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x))
|
||||
#define MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x))
|
||||
#define MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x))
|
||||
|
||||
#define MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y))
|
||||
#define MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y))
|
||||
|
||||
#define MKCOLOUR_0000 MKCOLOUR_XXXX(0x00)
|
||||
#define MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF)
|
||||
#define MKCOLOUR_F00F MKCOLOUR_X00X(0xFF)
|
||||
#define MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF)
|
||||
|
||||
#include "table/heightmap_colours.h"
|
||||
#include "table/darklight_colours.h"
|
||||
|
||||
/** Colour scheme of the smallmap. */
|
||||
struct SmallMapColourScheme {
|
||||
uint32 *height_colours; ///< Cached colours for each level in a map.
|
||||
const uint32 *height_colours_base; ///< Base table for determining the colours
|
||||
size_t colour_count; ///< The number of colours.
|
||||
uint32 default_colour; ///< Default colour of the land.
|
||||
};
|
||||
|
||||
extern SmallMapColourScheme _heightmap_schemes[];
|
||||
|
||||
struct AndOr {
|
||||
uint32 mor;
|
||||
uint32 mand;
|
||||
};
|
||||
|
||||
static inline uint32 ApplyMask(uint32 colour, const AndOr *mask)
|
||||
{
|
||||
return (colour & mask->mand) | mask->mor;
|
||||
}
|
||||
|
||||
/** Colour masks for "Contour" and "Routes" modes. */
|
||||
static const AndOr _smallmap_contours_andor[] = {
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_CLEAR
|
||||
{MKCOLOUR_0XX0(PC_GREY ), MKCOLOUR_F00F}, // MP_RAILWAY
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_ROAD
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_HOUSE
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TREES
|
||||
{MKCOLOUR_XXXX(PC_LIGHT_BLUE), MKCOLOUR_0000}, // MP_STATION
|
||||
{MKCOLOUR_XXXX(PC_WATER ), MKCOLOUR_0000}, // MP_WATER
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_VOID
|
||||
{MKCOLOUR_XXXX(PC_DARK_RED ), MKCOLOUR_0000}, // MP_INDUSTRY
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TUNNELBRIDGE
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_OBJECT
|
||||
{MKCOLOUR_0XX0(PC_GREY ), MKCOLOUR_F00F},
|
||||
};
|
||||
|
||||
/** Colour masks for "Vehicles", "Industry", and "Vegetation" modes. */
|
||||
static const AndOr _smallmap_vehicles_andor[] = {
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_CLEAR
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_RAILWAY
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_ROAD
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_HOUSE
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TREES
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_STATION
|
||||
{MKCOLOUR_XXXX(PC_WATER ), MKCOLOUR_0000}, // MP_WATER
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_VOID
|
||||
{MKCOLOUR_XXXX(PC_DARK_RED ), MKCOLOUR_0000}, // MP_INDUSTRY
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TUNNELBRIDGE
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_OBJECT
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F},
|
||||
};
|
||||
|
||||
static const uint32 _vegetation_clear_bits[] = {
|
||||
MKCOLOUR_XXXX(PC_GRASS_LAND), ///< full grass
|
||||
MKCOLOUR_XXXX(PC_ROUGH_LAND), ///< rough land
|
||||
MKCOLOUR_XXXX(PC_GREY), ///< rocks
|
||||
MKCOLOUR_XXXX(PC_FIELDS), ///< fields
|
||||
MKCOLOUR_XXXX(PC_LIGHT_BLUE), ///< snow
|
||||
MKCOLOUR_XXXX(PC_ORANGE), ///< desert
|
||||
MKCOLOUR_XXXX(PC_GRASS_LAND), ///< unused
|
||||
MKCOLOUR_XXXX(PC_GRASS_LAND), ///< unused
|
||||
};
|
||||
|
||||
#endif /* SMALLMAP_COLOURS_H */
|
@ -0,0 +1,52 @@
|
||||
/* $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 darklight_colours.h The colour tables to lighten and darken.
|
||||
*/
|
||||
|
||||
static const byte _lighten_colour[] = {
|
||||
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, // 0
|
||||
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x0F, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x0F, // 1
|
||||
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x0F, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, // 2
|
||||
0x31, 0x0F, 0x33, 0x34, 0x45, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x0F, 0x3D, 0x3E, 0x3F, 0x40, // 3
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x0F, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x0F, // 4
|
||||
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x0F, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x0F, // 5
|
||||
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x0F, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x0F, // 6
|
||||
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x0F, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x0F, // 7
|
||||
0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x0F, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x0F, // 8
|
||||
0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x0F, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, // 9
|
||||
0xA1, 0x0F, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x0F, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, // A
|
||||
0xB1, 0x0F, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x0F, // B
|
||||
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0x0F, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0x0F, 0xCF, 0xD0, // C
|
||||
0xD1, 0x0F, 0x0F, 0xD2, 0xD3, 0xD4, 0xD5, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0x0F, // D
|
||||
0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0x0F, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0x0F, 0xE3, // E
|
||||
0xE8, 0xF2, 0xF3, 0xCE, 0x44, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x0F, 0xFC, 0xFD, 0xFF, // F
|
||||
};
|
||||
|
||||
static const byte _darken_colour[] = {
|
||||
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 0
|
||||
0x02, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x02, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, // 1
|
||||
0x02, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x02, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, // 2
|
||||
0x2F, 0x30, 0x42, 0x32, 0x33, 0x02, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x02, 0x3C, 0x3D, 0x3E, // 3
|
||||
0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x01, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, // 4
|
||||
0x02, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x02, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, // 5
|
||||
0x02, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x02, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, // 6
|
||||
0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0xEF, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, // 7
|
||||
0x02, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x02, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, // 8
|
||||
0x02, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x02, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, // 9
|
||||
0x9F, 0xA0, 0xB4, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0x02, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, // A
|
||||
0xAF, 0xB0, 0x02, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, // B
|
||||
0x3F, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0x02, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xF3, 0xCE, // C
|
||||
0xCF, 0xD0, 0xD3, 0xD4, 0xD5, 0xD6, 0xDF, 0x02, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, // D
|
||||
0xE1, 0xE2, 0x02, 0xEF, 0xE3, 0xE4, 0xE5, 0xE6, 0xB8, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0x02, // E
|
||||
0xB5, 0x02, 0xF1, 0xF2, 0x43, 0x02, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFE, 0xF5, 0x0F // F
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
||||
/* $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 plans_widget.h Types related to the plans widgets. */
|
||||
|
||||
#ifndef WIDGETS_PLANS_WIDGET_H
|
||||
#define WIDGETS_PLANS_WIDGET_H
|
||||
|
||||
/** Widgets of the #PlansWindow class. */
|
||||
enum PlansWidgets {
|
||||
WID_PLN_CAPTION, ///< Caption of the window.
|
||||
WID_PLN_LIST,
|
||||
WID_PLN_SCROLLBAR,
|
||||
WID_PLN_NEW,
|
||||
WID_PLN_ADD_LINES,
|
||||
WID_PLN_VISIBILITY,
|
||||
WID_PLN_HIDE_ALL,
|
||||
WID_PLN_DELETE,
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_PLANS_WIDGET_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue