Create stdext net, changes to outfit and exit windows.

This commit is contained in:
Henrique Santiago 2012-08-06 22:11:42 -03:00
parent 54f4e2b801
commit a2db210012
8 changed files with 113 additions and 30 deletions

View File

@ -1,15 +1,13 @@
ExitWindow < MainWindow ExitWindow < MainWindow
id: exitWindow id: exitWindow
!text: tr('Exit') !text: tr('Exit')
size: 550 135 size: 570 135
Label Label
!text: tr("If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character.") !text: tr("If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character.")
width: 500 text-auto-resize: true
height: 45 anchors.horizontalCenter: parent.horizontalCenter
anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin-left: 10
margin-top: 2 margin-top: 2
Button Button

View File

@ -10,25 +10,20 @@ NextMountButton < NextButton
PrevMountButton < PreviousButton PrevMountButton < PreviousButton
icon-source: /images/arrow_left.png icon-source: /images/arrow_left.png
Window MainWindow
!text: tr('Select Outfit') !text: tr('Select Outfit')
size: 338 375 size: 338 375
padding: 0 0 0 0
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
@onEnter: modules.game_outfit.accept() @onEnter: modules.game_outfit.accept()
@onEscape: modules.game_outfit.destroy() @onEscape: modules.game_outfit.destroy()
// Creature Boxes // Creature Boxes
Creature Creature
id: outfitCreatureBox id: outfitCreatureBox
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
margin-top: 48 margin-top: 15
margin-left: 40 margin-left: 22
padding: 4 4 4 4 padding: 4 4 4 4
fixed-creature-size: true fixed-creature-size: true
@ -60,8 +55,8 @@ Window
id: mountCreatureBox id: mountCreatureBox
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
margin-top: 48 margin-top: 15
margin-right: 40 margin-right: 22
padding: 4 4 4 4 padding: 4 4 4 4
fixed-creature-size: true fixed-creature-size: true
@ -98,7 +93,7 @@ Window
anchors.top: outfitCreatureBox.bottom anchors.top: outfitCreatureBox.bottom
anchors.left: parent.left anchors.left: parent.left
margin-top: 6 margin-top: 6
margin-left: 18 margin-left: 2
enabled: false enabled: false
CheckBox CheckBox
@ -182,8 +177,6 @@ Window
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: next.top anchors.bottom: next.top
margin-left: 16
margin-right: 16
margin-bottom: 10 margin-bottom: 10
margin-top: 5 margin-top: 5
@ -193,7 +186,6 @@ Window
width: 64 width: 64
anchors.right: next.left anchors.right: next.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin-bottom: 16
margin-right: 16 margin-right: 16
@onClick: modules.game_outfit.accept() @onClick: modules.game_outfit.accept()
@ -203,6 +195,4 @@ Window
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin-bottom: 16
margin-right: 16
@onClick: modules.game_outfit.destroy() @onClick: modules.game_outfit.destroy()

View File

@ -44,6 +44,8 @@ set(framework_SOURCES ${framework_SOURCES}
${CMAKE_CURRENT_LIST_DIR}/stdext/format.h ${CMAKE_CURRENT_LIST_DIR}/stdext/format.h
${CMAKE_CURRENT_LIST_DIR}/stdext/math.cpp ${CMAKE_CURRENT_LIST_DIR}/stdext/math.cpp
${CMAKE_CURRENT_LIST_DIR}/stdext/math.h ${CMAKE_CURRENT_LIST_DIR}/stdext/math.h
${CMAKE_CURRENT_LIST_DIR}/stdext/net.cpp
${CMAKE_CURRENT_LIST_DIR}/stdext/net.h
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_any.h ${CMAKE_CURRENT_LIST_DIR}/stdext/packed_any.h
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_storage.h ${CMAKE_CURRENT_LIST_DIR}/stdext/packed_storage.h
${CMAKE_CURRENT_LIST_DIR}/stdext/packed_vector.h ${CMAKE_CURRENT_LIST_DIR}/stdext/packed_vector.h

View File

@ -32,6 +32,7 @@
#include <framework/util/crypt.h> #include <framework/util/crypt.h>
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <framework/graphics/texturemanager.h> #include <framework/graphics/texturemanager.h>
#include <framework/stdext/net.h>
#ifdef FW_GRAPHICS #ifdef FW_GRAPHICS
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "net.h"
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <arpa/inet.h>
namespace stdext {
std::string ip_to_string(uint32 ip)
{
char host[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &ip, host, INET_ADDRSTRLEN);
return std::string(host);
}
uint32 string_to_ip(const std::string& string)
{
uint32 ip = 0;
inet_pton(AF_INET, string.c_str(), &ip);
return ip;
}
void listSubnetAddresses(std::string subnet, std::vector<uint32>& list)
{
std::vector<std::string> strVec;
boost::split(strVec, subnet, boost::is_any_of("/"));
uint32 address = inet_addr(strVec[0].c_str());
if(address != INADDR_NONE && strVec.size() == 2) {
uint32 mask = boost::lexical_cast<uint32>(strVec[1]);
if(mask <= 32) {
for(uint32 i=0; i <= (0xFFFFFFFF >> mask); i++) {
uint32 ip = htonl((htonl(address) & (~(0xFFFFFFFF >> mask))) | i);
if((ip >> 24) != 0 && (ip >> 24) != 0xFF) {
list.push_back(ip);
}
}
}
}
}
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef STDEXT_NET_H
#define STDEXT_NET_H
#include "types.h"
#include <string>
#include <vector>
namespace stdext {
std::string ip_to_string(uint32 ip);
uint32 string_to_ip(const std::string& string);
void listSubnetAddresses(std::string subnet, std::vector<uint32>& list);
}
#endif

View File

@ -66,13 +66,6 @@ uint64_t hex_to_dec(const std::string& str)
return num; return num;
} }
std::string ip_to_string(uint32_t ip)
{
char host[16];
sprintf(host, "%d.%d.%d.%d", (uint8_t)ip, (uint8_t)(ip >> 8), (uint8_t)(ip >> 16), (uint8_t)(ip >> 24));
return std::string(host);
}
std::string utf8_to_latin1(uchar *utf8) std::string utf8_to_latin1(uchar *utf8)
{ {
auto utf8CharToLatin1 = [](uchar *utf8, int *read) -> char { auto utf8CharToLatin1 = [](uchar *utf8, int *read) -> char {
@ -142,4 +135,4 @@ std::vector<std::string> split(const std::string& str, const std::string& separa
return splitted; return splitted;
} }
} }

View File

@ -42,7 +42,6 @@ std::string date_time_string();
std::string dec_to_hex(uint64_t num); std::string dec_to_hex(uint64_t num);
uint64_t hex_to_dec(const std::string& str); uint64_t hex_to_dec(const std::string& str);
std::string ip_to_string(uint32_t ip);
std::string utf8_to_latin1(uchar *utf8); std::string utf8_to_latin1(uchar *utf8);
void tolower(std::string& str); void tolower(std::string& str);
void toupper(std::string& str); void toupper(std::string& str);