project_files/HedgewarsMobile/Classes/ExtraCategories.m
author sheepluva
Sun, 08 Dec 2019 02:09:19 +0100
branchhedgeroid
changeset 15520 de08a3ae4f8d
parent 13172 c129707eb1e6
permissions -rw-r--r--
hedgeroid/frontlib: update proto and weapons number
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     1
/*
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     3
 * Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com>
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     4
 *
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     8
 *
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    13
 *
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 6832
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    17
 */
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    18
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    19
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    20
#import "ExtraCategories.h"
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    21
#import <QuartzCore/QuartzCore.h>
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    22
#import <CommonCrypto/CommonDigest.h>
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    23
6209
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    24
6300
db8fd3ff693c move two class files in a correct directory
koda
parents: 6210
diff changeset
    25
#pragma mark -
6209
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    26
@implementation UIScreen (safe)
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    27
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
    28
- (CGFloat)safeScale {
6209
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    29
    CGFloat theScale = 1.0f;
11140
3fbe54013b2b - 'safeScale' now always 1.0
antonc27 <antonc27@mail.ru>
parents: 11104
diff changeset
    30
//    if ([self respondsToSelector:@selector(scale)])
3fbe54013b2b - 'safeScale' now always 1.0
antonc27 <antonc27@mail.ru>
parents: 11104
diff changeset
    31
//         theScale = [self scale];
6209
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    32
    return theScale;
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    33
}
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    34
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
    35
- (CGRect)safeBounds {
11104
eea0481d2ae1 - Some weird staff with bounds commented here
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    36
    return [self bounds];
eea0481d2ae1 - Some weird staff with bounds commented here
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    37
//    CGRect original = [self bounds];
eea0481d2ae1 - Some weird staff with bounds commented here
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    38
//    if (IS_ON_PORTRAIT())
eea0481d2ae1 - Some weird staff with bounds commented here
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    39
//        return original;
eea0481d2ae1 - Some weird staff with bounds commented here
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    40
//    else
eea0481d2ae1 - Some weird staff with bounds commented here
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    41
//        return CGRectMake(original.origin.x, original.origin.y, original.size.height, original.size.width);
6615
65602f1ef0f8 more ios pages supporting rotaiton
koda
parents: 6300
diff changeset
    42
}
65602f1ef0f8 more ios pages supporting rotaiton
koda
parents: 6300
diff changeset
    43
6209
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    44
@end
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    45
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6208
diff changeset
    46
6300
db8fd3ff693c move two class files in a correct directory
koda
parents: 6210
diff changeset
    47
#pragma mark -
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    48
@implementation UITableView (backgroundColor)
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    49
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
    50
- (void)setBackgroundColorForAnyTable:(UIColor *) color {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    51
    if ([self respondsToSelector:@selector(backgroundView)]) {
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    52
        UIView *backView = [[UIView alloc] initWithFrame:self.frame];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    53
        backView.backgroundColor = color;
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    54
        self.backgroundView = backView;
6210
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6209
diff changeset
    55
        self.backgroundColor = [UIColor clearColor];
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6209
diff changeset
    56
    } else
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6209
diff changeset
    57
        self.backgroundColor = color;
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    58
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    59
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    60
@end
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    61
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    62
6300
db8fd3ff693c move two class files in a correct directory
koda
parents: 6210
diff changeset
    63
#pragma mark -
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    64
@implementation UIColor (HWColors)
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    65
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
    66
+ (UIColor *)darkYellowColor {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    67
    return [UIColor colorWithRed:(CGFloat)0xFE/255 green:(CGFloat)0xC0/255 blue:0 alpha:1];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    68
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    69
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
    70
+ (UIColor *)lightYellowColor {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    71
    return [UIColor colorWithRed:(CGFloat)0xF0/255 green:(CGFloat)0xD0/255 blue:0 alpha:1];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    72
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    73
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
    74
+ (UIColor *)darkBlueColor {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    75
    return [UIColor colorWithRed:(CGFloat)0x0F/255 green:0 blue:(CGFloat)0x42/255 alpha:1];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    76
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    77
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    78
// older devices don't get any transparency for performance reasons
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
    79
+ (UIColor *)darkBlueColorTransparent {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    80
    return [UIColor colorWithRed:(CGFloat)0x0F/255
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    81
                           green:0
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    82
                            blue:(CGFloat)0x55/255
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    83
                           alpha:IS_NOT_POWERFUL([HWUtils modelType]) ? 1 : 0.6f];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    84
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    85
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
    86
+ (UIColor *)blackColorTransparent {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    87
    return [UIColor colorWithRed:0
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    88
                           green:0
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    89
                            blue:0
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    90
                           alpha:IS_NOT_POWERFUL([HWUtils modelType]) ? 1 : 0.65f];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    91
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    92
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    93
@end
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    94
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
    95
6300
db8fd3ff693c move two class files in a correct directory
koda
parents: 6210
diff changeset
    96
#pragma mark -
6711
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
    97
@implementation UIButton (quickStyle)
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
    98
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
    99
- (id)initWithFrame:(CGRect)frame andTitle:(NSString *)title {
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   100
    if (!(self = [self initWithFrame:frame])) return nil;
6711
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   101
    [self setTitle:title forState:UIControlStateNormal];
11145
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   102
    [self applyBlackQuickStyle];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   103
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   104
    return self;
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   105
}
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   106
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   107
- (void)applyBlackQuickStyle
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   108
{
6711
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   109
    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   110
    [self setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   111
    self.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   112
    self.backgroundColor = [UIColor blackColorTransparent];
11145
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   113
    
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   114
    [self.layer setBorderWidth:1.0f];
6711
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   115
    [self.layer setBorderColor:[[UIColor darkYellowColor] CGColor]];
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   116
    [self.layer setCornerRadius:9.0f];
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   117
    [self.layer setMasksToBounds:YES];
11145
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   118
}
6711
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   119
11145
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   120
- (void)applyDarkBlueQuickStyle
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   121
{
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   122
    [self setTitleColor:[UIColor darkYellowColor] forState:UIControlStateNormal];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   123
    [self setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   124
    self.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   125
    self.backgroundColor = [UIColor darkBlueColorTransparent];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   126
    
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   127
    [self.layer setBorderWidth:2.0f];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   128
    [self.layer setBorderColor:[[UIColor darkYellowColor] CGColor]];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   129
    [self.layer setCornerRadius:9.0f];
1c89970c7f15 - Restyle of 'Simple' and 'Missions' buttons at Main screen
antonc27 <antonc27@mail.ru>
parents: 11140
diff changeset
   130
    [self.layer setMasksToBounds:YES];
6711
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   131
}
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   132
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   133
@end
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   134
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   135
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   136
#pragma mark -
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   137
@implementation UILabel (quickStyle)
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   138
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   139
- (id)initWithFrame:(CGRect)frame andTitle:(NSString *)title {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   140
    return [self initWithFrame:frame
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   141
                      andTitle:title
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   142
               withBorderWidth:1.5f
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   143
               withBorderColor:[UIColor darkYellowColor]
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   144
           withBackgroundColor:[UIColor darkBlueColor]];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   145
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   146
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   147
- (id)initWithFrame:(CGRect)frame andTitle:(NSString *)title withBorderWidth:(CGFloat)borderWidth {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   148
    return [self initWithFrame:frame
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   149
                      andTitle:title
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   150
               withBorderWidth:borderWidth
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   151
               withBorderColor:[UIColor darkYellowColor]
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   152
           withBackgroundColor:[UIColor darkBlueColorTransparent]];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   153
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   154
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   155
- (id)initWithFrame:(CGRect)frame andTitle:(NSString *)title withBorderWidth:(CGFloat)borderWidth
6711
76e96101a84f prepare a styled button
koda
parents: 6700
diff changeset
   156
          withBorderColor:(UIColor *)borderColor withBackgroundColor:(UIColor *)backColor {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   157
    UILabel *theLabel = [self initWithFrame:frame];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   158
    theLabel.backgroundColor = backColor;
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   159
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   160
    if (title != nil) {
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   161
        theLabel.text = title;
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   162
        theLabel.textColor = [UIColor lightYellowColor];
11554
893722a2a1f9 - Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents: 11145
diff changeset
   163
        theLabel.textAlignment = NSTextAlignmentCenter;
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   164
        theLabel.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]*80/100];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   165
    }
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   166
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   167
    [theLabel.layer setBorderWidth:borderWidth];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   168
    [theLabel.layer setBorderColor:borderColor.CGColor];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   169
    [theLabel.layer setCornerRadius:8.0f];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   170
    [theLabel.layer setMasksToBounds:YES];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   171
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   172
    return theLabel;
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   173
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   174
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   175
@end
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   176
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   177
6300
db8fd3ff693c move two class files in a correct directory
koda
parents: 6210
diff changeset
   178
#pragma mark -
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   179
@implementation NSString (MD5)
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   180
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
   181
- (NSString *)MD5hash {
6208
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   182
    const char *cStr = [self UTF8String];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   183
    unsigned char result[16];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   184
    CC_MD5( cStr, strlen(cStr), result );
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   185
    return [NSString stringWithFormat:
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   186
            @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   187
            result[0], result[1], result[2], result[3], result[4], result[5],
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   188
            result[6], result[7], result[8], result[9], result[10], result[11],
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   189
            result[12], result[13], result[14], result[15]];
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   190
}
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   191
b831679e9467 move all extra categories in a single source, add caching for HWUtils
koda
parents:
diff changeset
   192
@end
13172
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   193
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   194
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   195
#pragma mark -
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   196
@implementation NSUserDefaults (setNonExisting)
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   197
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   198
- (void)setDefaultValue:(nullable id)value forNonExistingKey:(NSString *_Nonnull)key {
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   199
    if ([self objectForKey:key] == nil) {
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   200
        [self setObject:value forKey:key];
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   201
    }
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   202
}
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   203
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   204
- (void)setDefaultBool:(BOOL)boolValue forNonExistingKey:(NSString *_Nonnull)key {
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   205
    [self setDefaultValue:[NSNumber numberWithBool:boolValue] forNonExistingKey:key];
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   206
}
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   207
c129707eb1e6 - Remember user settings on app update
antonc27 <antonc27@mail.ru>
parents: 13171
diff changeset
   208
@end