File: Config.cpp

package info (click to toggle)
numptyphysics 0.2+svn157-0.3
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 2,596 kB
  • ctags: 2,896
  • sloc: cpp: 18,280; sh: 810; makefile: 205
file content (64 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * This file is part of NumptyPhysics
 * Copyright (C) 2008 Tim Edmonds
 * 
 * This program 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; either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program 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.
 *
 */

#include "Config.h"
#include "Font.h"


Rect FULLSCREEN_RECT( 0, 0, WORLD_WIDTH-1, WORLD_HEIGHT-1 );

const Rect BOUNDS_RECT( -WORLD_WIDTH/4, -WORLD_HEIGHT,
			WORLD_WIDTH*5/4, WORLD_HEIGHT );
int SCREEN_WIDTH = WORLD_WIDTH;
int SCREEN_HEIGHT = WORLD_HEIGHT;

const int brushColours[] = {
  0xb80000, //red
  0xeec900, //yellow
  0x000077, //blue
  0x108710, //green
  0x101010, //black
  0x8b4513, //brown
  0x87cefa, //lightblue
  0xee6aa7, //pink
  0xb23aee, //purple
  0x00fa9a, //lightgreen
  0xff7f00, //orange
  0x6c7b8b, //grey
};

const int NUM_BRUSHES = (sizeof(brushColours)/sizeof(brushColours[0]));

std::string Config::findFile( const std::string& name )
{
  std::string p( "data/" );
  FILE *fd = fopen( (p+name).c_str(), "rb"  );
  if ( !fd ) {
    p = std::string( DEFAULT_RESOURCE_PATH "/" );
    fd = fopen( (p+name).c_str(), "rb" );
  }
  if ( fd ) {
    fclose(fd);
    return p+name;
  }
  return name;
}

Font* Config::font()
{
  static Font f("font.npf");
  return &f;
}