Logo Search packages:      
Sourcecode: freecraft version File versions  Download package

ui.h

//   ___________             _________                _____  __
//   \_       _____/______   ____   ____ \_   ___ \____________ _/ ____\/  |_
//    |    __) \_  __ \_/ __ \_/ __ \/    \  \/\_  __ \__  \\   __\\   __|
//    |     \   |  | \/\  ___/\  ___/\     \____|  | \// __ \|  |   |  |
//    \___  /   |__|    \___  >\___  >\______  /|__|  (____  /__|   |__|
//      \/            \/         \/      \/              \/
//  ______________________                           ______________________
//                  T H E   W A R   B E G I N S
//       FreeCraft - A free fantasy real time strategy game engine
//
/**@name ui.h           -     The user interface header file. */
//
//    (c) Copyright 1999-2002 by Lutz Sammer
//
//    FreeCraft 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; only version 2 of the License.
//
//    FreeCraft 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.
//
//    $Id: ui.h,v 1.46 2003/01/30 22:01:59 jsalmon3 Exp $

#ifndef __UI_H__
#define __UI_H__

//@{

// FIXME: this only the start of the new user interface
// FIXME: all user interface variables should go here and be configurable

/*----------------------------------------------------------------------------
--    Includes
----------------------------------------------------------------------------*/

#include "video.h"
#include "upgrade_structs.h"
#include "cursor.h"

/*----------------------------------------------------------------------------
--    Definitons
----------------------------------------------------------------------------*/

/**
**    Defines the default SVGALIB mouse speed adjust (must be > 0)
*/
#define MOUSEADJUST     15

/**
**    Defines the default SVGALIB mouse speed scale
*/
#define MOUSESCALE      1

    /// MACRO - HARDCODED NUMBER OF BUTTONS on screen
#define MaxButtons      19

    /// typedef for buttons on screen themselves
typedef struct _button_ Button;

    /// buttons on screen themselves
00063 struct _button_ {
    int           X;                /// x coordinate on the screen
00065     int           Y;                /// y coordinate on the screen
00066     int         Width;              /// width of the button on the screen
00067     int         Height;             /// height of the button on the screen
};

#define MAX_NUM_VIEWPORTS 8         /// Number of supported viewports

#if !defined(__STRUCT_VIEWPORT__)
#define __STRUCT_VIEWPORT__         /// protect duplicate viewport typedef
typedef struct _viewport_ Viewport; /// Viewport typedef
#endif

/**
**    A map viewport.
**
**    A part of the map displayed on sceen.
**
**    Viewport::X Viewport::Y
**    Viewport::EndX Viewport::EndY
**
**          upper left corner of this viewport is located at pixel
**          coordinates (X, Y) with respect to upper left corner of
**          freecraft's window, similarly lower right corner of this
**          viewport is (EndX, EndY) pixels away from the UL corner of
**          freecraft's window.
**
**    Viewport::MapX Viewport::MapY
**    Viewport::MapWidth Viewport::MapHeight
**
**          Tile coordinates of UL corner of this viewport with respect to
**          UL corner of the whole map.
**
**    Viewport::Unit
**
**          Viewport is bound to an unit. If the unit moves the viewport
**          changes the position together with the unit.
**          @todo binding to a group.
*/
00103 struct _viewport_ {
    int X;              /// Screen pixel left corner x coordinate
00105     int Y;              /// Screen pixel upper corner y coordinate
00106     int EndX;                 /// Screen pixel right x coordinate
00107     int EndY;                 /// Screen pixel bottom y coordinate

00109     int MapX;                 /// Map tile left corner x coordinate
00110     int MapY;                 /// Map tile upper corner y coordinate
00111     int MapWidth;       /// Width in map tiles
00112     int MapHeight;            /// Height in map tiles

00114     Unit* Unit;               /// Bound to this unit
};

/**
**    Enumeration of the different predefined viewport configurations.
**
**    @todo this should be later user configurable
*/
typedef enum {
    VIEWPORT_SINGLE,          /// Old single viewport
    VIEWPORT_SPLIT_HORIZ,     /// Two viewports split horizontal
    VIEWPORT_SPLIT_HORIZ3,    /// Three viewports split horiontal
    VIEWPORT_SPLIT_VERT,      /// Two viewports split vertical
    VIEWPORT_QUAD,            /// Four viewports split symmetric
    NUM_VIEWPORT_MODES        /// Number of different viewports.
} ViewportMode;

/**
**    Panel types used in menus (and stored in ui global below)
*/
enum {
    ImageNone,
    ImagePanel1,  // 256 x 288
    ImagePanel2,  // 288 x 256
    ImagePanel3,  // 384 x 256
    ImagePanel4,  // 288 x 128
    ImagePanel5,  // 352 x 352
    ScPanel,            // transparent any size
};

/**
**    Defines the user interface.
*/
00147 typedef struct _ui_ {
    // to select the correct user interface.
    char*   Name;             /// interface name to select
00150     int           Width;                  /// useable for this width
00151     int           Height;                 /// useable for this height

00153     int           Contrast;         /// General Contrast
00154     int           Brightness;       /// General Brightness
00155     int           Saturation;       /// General Saturation

00157     int           MouseScroll;            /// Enable mouse scrolling
00158     int           KeyScroll;        /// Enable keyboard scrolling
      /// Middle mouse button map move with reversed directions
00160     char    ReverseMouseMove;

    int           WarpX;                  /// Cursor warp X position
00163     int           WarpY;                  /// Cursor warp Y position

00165     int           MouseAdjust;            /// Mouse speed adjust
00166     int           MouseScale;       /// Mouse speed scale

00168     char    NormalFontColor;  /// Color for normal text displayed
00169     char    ReverseFontColor; /// Color for reverse text displayed

    //      Fillers
00172     GraphicConfig Filler1;          /// filler 1 graphic
00173     int           Filler1X;         /// filler 1 X position
00174     int           Filler1Y;         /// filler 1 Y position

    //      Resource line
00177     GraphicConfig Resource;         /// Resource background
00178     int           ResourceX;        /// Resource X position
00179     int           ResourceY;        /// Resource Y position

00181     int           OriginalResources;      /// original resource mode

    struct {
#if 0
      int   IconX;                  /// Icon X position
      int   IconY;                  /// Icon Y position
      IconConfig  Icon;       /// Icon for resource
      int   TextX;                  /// Text X position
      int   TextX;                  /// Text Y position
      char* Text;             /// Text for resource
      int   AmountX;          /// Amount X position
      int   AmountY;          /// Amount Y position
#endif
      GraphicConfig Icon;           /// icon image
00195       int   IconRow;          /// icon image row (frame)
00196       int   IconX;                  /// icon X position
00197       int   IconY;                  /// icon Y position
00198       int   IconW;                  /// icon W position
00199       int   IconH;                  /// icon H position
00200       int   TextX;                  /// text X position
00201       int   TextY;                  /// text Y position
    }       Resources[MaxCosts];    /// Icon+Text of all resources

00204     GraphicConfig FoodIcon;         /// units icon image
00205     int           FoodIconRow;            /// units icon image row (frame)
00206     int           FoodIconX;        /// units icon X position
00207     int           FoodIconY;        /// units icon Y position
00208     int           FoodIconW;        /// units icon W position
00209     int           FoodIconH;        /// units icon H position
00210     int           FoodTextX;        /// units text X position
00211     int           FoodTextY;        /// units text Y position

00213     GraphicConfig ScoreIcon;        /// score icon image
00214     int           ScoreIconRow;           /// score icon image row (frame)
00215     int           ScoreIconX;       /// score icon X position
00216     int           ScoreIconY;       /// score icon Y position
00217     int           ScoreIconW;       /// score icon W position
00218     int           ScoreIconH;       /// score icon H position
00219     int           ScoreTextX;       /// score text X position
00220     int           ScoreTextY;       /// score text Y position

    // Info panel
00223     GraphicConfig InfoPanel;        /// Info panel background
00224     int           InfoPanelX;       /// Info panel screen X position
00225     int           InfoPanelY;       /// Info panel screen Y position
00226     int           InfoPanelW;       /// Info panel width
00227     int           InfoPanelH;       /// Info panel height

    // Complete bar
00230     int           CompleteBarColor; /// color for complete bar
00231     int           CompleteBarX;           /// complete bar X position
00232     int           CompleteBarY;           /// complete bar Y position
00233     int           CompleteTextX;          /// complete text X position
00234     int           CompleteTextY;          /// complete text Y position

    // Button panel
00237     GraphicConfig ButtonPanel;            /// Button panel background
00238     int           ButtonPanelX;           /// Button panel screen X position
00239     int           ButtonPanelY;           /// Button panel screen Y position

    // Map area
00242     ViewportMode ViewportMode;            /// Current viewport mode
00243     Viewport*     MouseViewport;          /// Viewport containing mouse
00244     Viewport*     SelectedViewport; /// Current selected active viewport
00245     int           NumViewports;           /// # Viewports currently used
00246     Viewport      Viewports[MAX_NUM_VIEWPORTS]; /// Parameters of all viewports
    // Map* attributes of Viewport are unused here:
00248     Viewport      MapArea;          /// geometry of the whole map area

    // The menu button
00251     GraphicConfig MenuButton;       /// menu button background
00252     int           MenuButtonX;            /// menu button screen X position
00253     int           MenuButtonY;            /// menu button screen Y position

    // The minimap
00256     GraphicConfig Minimap;          /// minimap panel background
00257     int           MinimapX;         /// minimap screen X position
00258     int           MinimapY;         /// minimap screen Y position
00259     int           ViewportCursorColor;    /// minimap cursor color

    // The status line
00262     GraphicConfig StatusLine;       /// Status line background
00263     int           StatusLineX;            /// status line screeen X position
00264     int           StatusLineY;            /// status line screeen Y position

      /// all buttons (1 Menu, 9 Group, 9 Command)
00267     Button  Buttons[MaxButtons];
      /// used for displaying unit training queues
00269     Button  Buttons2[6];

    // Offsets for 640x480 center used by menus
    int           Offset640X;       /// Offset for 640x480 X position
00273     int           Offset480Y;       /// Offset for 640x480 Y position

    //
    //      Cursors used.
    //
00278     CursorConfig  Point;            /// General pointing cursor
00279     CursorConfig  Glass;            /// HourGlass, system is waiting
00280     CursorConfig  Cross;            /// Multi-select cursor.
00281     CursorConfig  YellowHair; /// Yellow action,attack cursor.
00282     CursorConfig  GreenHair;  /// Green action,attack cursor.
00283     CursorConfig  RedHair;    /// Red action,attack cursor.
00284     CursorConfig  Scroll;           /// Cursor for scrolling map around.

00286     CursorConfig  ArrowE;           /// Cursor pointing east
00287     CursorConfig  ArrowNE;    /// Cursor pointing north east
00288     CursorConfig  ArrowN;           /// Cursor pointing north
00289     CursorConfig  ArrowNW;    /// Cursor pointing north west
00290     CursorConfig  ArrowW;           /// Cursor pointing west
00291     CursorConfig  ArrowSW;    /// Cursor pointing south west
00292     CursorConfig  ArrowS;           /// Cursor pointing south
00293     CursorConfig  ArrowSE;    /// Cursor pointing south east

// FIXME: could use different sounds/speach for the errors
// Is in gamesounds?
//    SoundConfig PlacementError;         /// played on placements errors
//    SoundConfig PlacementSuccess; /// played on placements success
//    SoundConfig Click;                  /// click noice used often

00301     GraphicConfig GameMenuePanel;   /// Panel 256 x 288
00302     GraphicConfig Menue1Panel;      /// Panel 288 x 256
00303     GraphicConfig Menue2Panel;      /// Panel 384 x 256
00304     GraphicConfig VictoryPanel;     /// Panel 288 x 128
00305     GraphicConfig ScenarioPanel;    /// Panel 352 x 352
} UI;

/*----------------------------------------------------------------------------
--    Variables
----------------------------------------------------------------------------*/

extern UI TheUI;              /// The user interface
extern UI** UI_Table;               /// All available user interfaces

extern char RightButtonAttacks;           /// right button 0 move, 1 attack.
extern char FancyBuildings;         /// Mirror buildings 1 yes, 0 now.

extern int SpeedKeyScroll;          /// Keyboard Scrolling Speed, in Frames
extern int SpeedMouseScroll;        /// Mouse Scrolling Speed, in Frames

/*----------------------------------------------------------------------------
--    Functions
----------------------------------------------------------------------------*/

extern void InitUserInterface(const char*);     /// initialize the ui
extern void LoadUserInterface(void);            /// load ui graphics
extern void SaveUserInterface(FILE*);           /// save the ui state
extern void CleanUserInterface(void);           /// clean up the ui
extern void UserInterfaceCclRegister(void);     /// register ccl features

    /// Called if the mouse is moved in Normal interface state
extern void UIHandleMouseMove(int x,int y);
    /// Called if any mouse button is pressed down
extern void UIHandleButtonDown(unsigned button);
    /// Called if any mouse button is released up
extern void UIHandleButtonUp(unsigned button);

    /// Restrict mouse cursor to viewport
extern void RestrictCursorToViewport(void);
    /// Restrict mouse cursor to minimap
extern void RestrictCursorToMinimap(void);

    /// Get viewport for screen pixel position
extern Viewport* GetViewport(int, int);
    /// Get viewport for tile map position
extern Viewport* MapTileGetViewport(int, int);
    /// Cycle through all available viewport modes
extern void CycleViewportMode(int);
    /// Select viewport mode
extern void SetViewportMode(ViewportMode mode);

    /// Convert screen X pixel to map tile
extern int Viewport2MapX(const Viewport* vp, int x);
    /// Convert screen Y pixel to map tile
extern int Viewport2MapY(const Viewport* vp, int y);
    /// Convert map tile to screen X pixel
extern int Map2ViewportX(const Viewport* vp, int x);
    /// Convert map tile to screen Y pixel
extern int Map2ViewportY(const Viewport* vp, int y);

    /// Set the current map view to x,y(upper,left corner)
extern void ViewportSetViewpoint(Viewport* vp, int x, int y);
    /// Center map on point in viewport
extern void ViewportCenterViewpoint(Viewport* vp, int x, int y);

    /// Returns true, if unit is visible on current map view
extern int UnitVisibleInViewport(const Viewport* vp, const Unit* unit);

//@}

#endif      // !__UI_H__

Generated by  Doxygen 1.6.0   Back to index