Atrinik Client 2.5
events/console.c
Go to the documentation of this file.
00001 /************************************************************************
00002 *            Atrinik, a Multiplayer Online Role Playing Game            *
00003 *                                                                       *
00004 *    Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team    *
00005 *                                                                       *
00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game)     *
00007 * and Crossfire (Multiplayer game for X-windows).                       *
00008 *                                                                       *
00009 * This program is free software; you can redistribute it and/or modify  *
00010 * it under the terms of the GNU General Public License as published by  *
00011 * the Free Software Foundation; either version 2 of the License, or     *
00012 * (at your option) any later version.                                   *
00013 *                                                                       *
00014 * This program is distributed in the hope that it will be useful,       *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017 * GNU General Public License for more details.                          *
00018 *                                                                       *
00019 * You should have received a copy of the GNU General Public License     *
00020 * along with this program; if not, write to the Free Software           *
00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             *
00022 *                                                                       *
00023 * The author can be reached at admin@atrinik.org                        *
00024 ************************************************************************/
00025 
00030 #include <global.h>
00031 
00034 void mouse_InputNumber()
00035 {
00036     static int timeVal = 1;
00037     int x, y;
00038 
00039     if (!(SDL_GetMouseState(&x, &y) & SDL_BUTTON(SDL_BUTTON_LEFT)))
00040     {
00041         timeVal = 1;
00042         return;
00043     }
00044 
00045     x = x - cur_widget[IN_NUMBER_ID]->x1;
00046     y = y - cur_widget[IN_NUMBER_ID]->y1;
00047 
00048     if (x < 230 || x > 237 || y < 5)
00049     {
00050         return;
00051     }
00052 
00053     /* Plus */
00054     if (y > 13)
00055     {
00056         x = atoi(text_input_string) + timeVal;
00057 
00058         if (x > cpl.nrof)
00059         {
00060             x = cpl.nrof;
00061         }
00062     }
00063     /* Minus */
00064     else
00065     {
00066         x = atoi(text_input_string) - timeVal;
00067 
00068         if (x < 1)
00069         {
00070             x = 1;
00071         }
00072     }
00073 
00074     snprintf(text_input_string, sizeof(text_input_string), "%d", x);
00075     text_input_count = (int) strlen(text_input_string);
00076     timeVal += (timeVal / 8) + 1;
00077 }