Exemple #1
0
void followCurrentDFCenter()
{
    int32_t newviewx;
    int32_t newviewy;
    int32_t viewsizex;
    int32_t viewsizey;
    int32_t newviewz;
    actualWindowSize(viewsizex,viewsizey);
    Gui::getViewCoords(newviewx,newviewy,newviewz);
    ssState.Position.x = newviewx + (viewsizex/2) - (ssState.Size.x / 2) + ssConfig.viewXoffset;
    ssState.Position.y = newviewy + (viewsizey/2) - (ssState.Size.y / 2) + ssConfig.viewYoffset;
    ssState.Position.z = newviewz + ssConfig.viewZoffset + 1;
}
Exemple #2
0
void Overlay::ReadTileLocations()
{
	fontx = df::global::init->font.small_font_dispx;
	fonty = df::global::init->font.small_font_dispy;

	actualWindowSize(width, height);
	
	DFHack::DFSDL_Surface * dfsurf = (DFHack::DFSDL_Surface *) SDL_GetVideoSurface();
	offsetx = fontx+((dfsurf->w) % fontx)/2;
	offsety = fontx+((dfsurf->h) % fonty)/2;
	if (!df::global::gamemode || *df::global::gamemode == game_mode::ADVENTURE)
	{
		//Adventure mode doesn't have a single-tile border around it.
		offsetx = offsetx - fontx;
		offsety = offsety - fonty;
	}

	ssState.ScreenW = fontx*width; 
	ssState.ScreenH = fonty*height;
}
Exemple #3
0
void followCurrentDFWindow()
{
    int32_t newviewx;
    int32_t newviewy;
    int32_t viewsizex;
    int32_t viewsizey;
    int32_t newviewz;
    int32_t mapx, mapy, mapz;
    // we take the rectangle you'd get if you scrolled the DF view closely around
    // map edges with a pen pierced through the center,
    // compute the scaling factor between this rectangle and the map bounds and then scale
    // the coords with this scaling factor
    /**
    +---+
    |W+-++----------+
    +-+-+---------+ |
    | |         | |
    | | inner   | |
    | |   rect. | |
    | |         | |
    | |         | |--- map boundary
    | +---------+ |
    +-------------+  W - corrected view
    */
    Maps::getSize((uint32_t &)mapx, (uint32_t &)mapy, (uint32_t &)mapz);
    mapx *= 16;
    mapy *= 16;

    actualWindowSize(viewsizex,viewsizey);
    float scalex = float (mapx) / float (mapx - viewsizex);
    float scaley = float (mapy) / float (mapy - viewsizey);

    Gui::getViewCoords(newviewx,newviewy,newviewz);
    newviewx = newviewx + (viewsizex / 2) - mapx / 2;
    newviewy = newviewy + (viewsizey / 2) - mapy / 2;

    ssState.Position.x = float (newviewx) * scalex - (ssState.Size.x / 2) + ssConfig.viewXoffset + mapx / 2;
    ssState.Position.y = float (newviewy) * scaley - (ssState.Size.y / 2) + ssConfig.viewYoffset + mapy / 2;
    ssState.Position.z = newviewz + ssConfig.viewZoffset + 1;
}