SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   SH5 Mods Workshop (https://www.subsim.com/radioroom/forumdisplay.php?f=249)
-   -   [REL] TWOS Recognition Manual for PC/Smartphone (https://www.subsim.com/radioroom/showthread.php?t=250448)

Kedishen 09-07-21 02:58 PM

[WIP] TWOS Recognition Manual for PC/Smartphone
 
This is not a mod for the game. It is an online Ship of all Nations manual viewable in any web browser.

I made it specifically to be used on a small android screen but it works fine on larger screens.

It can be found here:
Current: https://sh5soan.000webhostapp.com/soan/
Original:https://sh5soan.000webhostapp.com/soan/index_old.php

Just click on the category of ship you are looking for and the info for each ship will be available. Left and right arrow keys are also supported on PC.

For anybody that is concerned or interested about the code, here it is. Feel free to do what you want with it.

 

PHP Code:

<?php

/* 
##### index.php #####

Recognition manual for SH5 TWOS.

Code by Kedishen

Created: 2021/09/07
Last Edited: 2021/09/09

#####################
*/

// SHIP TYPE DEFINITIONS

const FREIGHTER            1;
const 
TANKER            2;
const 
WARSHIP            3;
const 
ESCORT            4;
const 
TROOPTRANSPORT    5;
const 
CARRIER            6;
const 
OTHER                7;

const 
CATEGORY_MAX         7;

/* .cfg file format example

[Unit]
ClassName=OMPaula
3DModelFileName=data/Sea/NOM_Paula/NOL_British
UnitType=108
MaxSpeed=10
Length=91.5
Width=15
Mast=30.1
Draft=3.8
Displacement=2500
DisplacementVariation=200
RenownAwarded=230
CrewComplement=20
SurvivalRate=80
SurvivalPercentage=60
RecManualCategory=Tanker
BowShape=Raked
Funnels=1
;Islands=1
ShowInRecognitionManual=Yes
;*********** THE END **************

*/

/* Array Format

  array (
    'ClassName' => 'BuV_Dock1',
    'UnitType' => '12',
    'MaxSpeed' => '0',
    'Length' => '130',
    'Width' => '40',
    'Mast' => '25',
    'Draft' => '7.5',
    'RecManualCategory' => '7',
    'img' => './ships/BuV_Dock1_sil.jpg',
  ),
  
 */
 
?>

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="jquery.min.js"></script>
<script src="sss.js"></script>
<link rel="stylesheet" href="sss.css" type="text/css" media="all">
<script>jQuery(function($) {$('.slider').sss();});</script>

<style>
body {
    margin: 0px;
    padding: 0px;
    font-family: Verdana, sans-serif;
    font-size: 12px;
    color: #FFFFFF;
}

.container {
  width: 100%; 
}

.category {
    position: absolute;
    top: 0px;
}

.filter {
    position: absolute;
    bottom: 0px;
}

.details {
    position: absolute;
    top: 0px;
    right: 0px;
}

.details p {
    background-color:rgba(0, 0, 0, 0.9);
}

p {
    padding: 5px;
    background-color:rgba(0, 0, 0, 0.4);
    margin: 1px;
}

p:hover {
    background-color:rgba(0, 0, 0, 0.5);
}

a:link, a:visited {
    text-decoration: none;
    color: #FFFFFF;
}

p#selected {
    background-color:rgba(0, 0, 0, 0.6)
}
</style>
</head>

<body>
    <div class="container">
<?php
// Check if a ship type has been specified
if ( isset ( $_GET["type"] ) == TRUE AND $_GET["type"] <= CATEGORY_MAX )
{
    
$test_category htmlspecialchars$_GET["type"] );
    
    
//Which type
    
switch ( $test_category )
    {
        case 
FREIGHTER// Freighter
        
case TANKER// Tanker
        
case WARSHIP// Warships
        
case ESCORT// Escort
        
case TROOPTRANSPORT// Troop Transport
        
case CARRIER// Carrier
        
case OTHER// Other
            
$category $test_category;
            break;
      default:
        
$category NULL;
    }    
    
    
// If a type has been specified
    
if ( is_null$category ) == FALSE )
    {
        
// Scan ships directory
        
$dir "ships";
        
$tmpFile scandir$dir);
        
//$cfgCount = 0;
        // Run through all ship files
        
for( $i 2$i count$tmpFile ); $i++ )
        {
            
// Only look at config files
            
if ( strpos$tmpFile[$i], '.cfg' ) == TRUE )
            {
                
$fileHandler fopen$dir."/".$tmpFile[$i], "r" ) or exit( "unable to open file ($fileHandler)" );
                
// If the file opened successfully
                
if ( $fileHandler )
                {
                    
// Run through each line of the file
                    
while ( !feof$fileHandler ) )
                    {
                        
$line fgets$fileHandler );
                        if ( 
strpos$line'=' ) ) // If the read line is option=value
                        
{
                            list( 
$opt $val ) = explode"=" $line ); // Split the options and values to seperate variables
                            
                            // Cut off any ****
                            
$opt trim $opt );
                            
$val trim $val );
                            
                            if ( 
strpos $val';' ) == TRUE // If the value has a comment after it, remove it
                            
{
                                
$val substr$val0strpos $val';' ) );
                            }
                            
                            switch ( 
$opt // Accept only options of interest
                            
{
                                case 
"ShowInRecognitionManual":
                                    switch ( 
$val )
                                    {
                                        case 
"YES":
                                            
$val 1;
                                            break;
                                        default:
                                            
$val 0;
                                    }
                                case 
"UnitType":
                                case 
"RecManualCategory":
                                    switch ( 
$val )    // Set ship category
                                    
{
                                        case 
"Freighter":         // Freighter
                                            
$val FREIGHTER;
                                            break;
                                        case 
"Tanker":             // Tanker
                                            
$val TANKER;
                                            break;
                                        case 
"LargeWarship":     // Warships
                                            
$val WARSHIP;
                                            break;
                                        case 
"EscortShip":         // Escort
                                            
$val ESCORT;
                                            break;
                                        case 
"TroopTransport":     // Troop Transport
                                            
$val TROOPTRANSPORT;
                                            break;
                                        case 
"AircraftCarrier":    // Carrier
                                            
$val CARRIER;
                                            break;
                                        case 
"Other":             // Other
                                            
$val OTHER;
                                            break;
                                    }
                                case 
"ClassName":
                                case 
"MaxSpeed":
                                case 
"Length":
                                case 
"Width":
                                case 
"Mast":
                                case 
"Displacement":
                                case 
"Draft":
                                    
$ships[$tmpFile[$i]][$opt] = $val;
                                    break;
                            }
                        }
                        unset( 
$opt );
                        unset( 
$val );
                    }
                    
                    
// Create ship image entry in array
                    
$imgsrc "./".$dir."/".substr $tmpFile[$i], 0, -)."_sil.jpg";
                    if ( 
is_null$imgsrc ) == FALSE )
                    {
                        if ( 
file_exists $imgsrc ) == TRUE )
                        {
                            
$ships[$tmpFile[$i]]["img"] = $imgsrc;
                        }
                    }
                    unset ( 
$imgsrc );
                }
                
fclose$fileHandler );
            }
        }
?>
        <div class="slider">
<?php
        
foreach ( $ships as $thing => $ship )
        {
            if ( isset ( 
$ship["ShowInRecognitionManual"] ) == FALSE OR $ship["ShowInRecognitionManual"] == 1  )
            {
                if ( isset ( 
$ship["RecManualCategory"] ) == TRUE AND $ship["RecManualCategory"] == $category )
                {
?>            
            <div>
                <img src="<?php print $ship["img"]; ?>" />
                <p class="details">    
<?php            
                    
print (isset ( $ship["ClassName"] ) )? "<u>".$ship["ClassName"]."</u><br />":"";
                    print (isset ( 
$ship["MaxSpeed"] ) )? "Speed : ".$ship["MaxSpeed"]."<br />":"";
                    print (isset ( 
$ship["Length"] ) )? "Length: ".$ship["Length"]."<br />":"";
                    print (isset ( 
$ship["Width"] ) )? "Width : ".$ship["Width"]."<br />":"";
                    print (isset ( 
$ship["Mast"] ) )? "Mast  : ".$ship["Mast"]."<br />":"";
                    print (isset ( 
$ship["Draft"] ) )? "Draft : ".$ship["Draft"]."<br />":"";
                    print (isset ( 
$ship["Displacement"] ) )? "Tons : ".$ship["Displacement"]."<br />":"";
?>
                </p>
            </div>
<?php
                
}
            }
        }
    }
?>
        </div>
<?php
}

if ( isset ( 
$category ) == FALSE ) { $category 1; }

?>
        <div class="filter">
<!-- BEGIN Menu control - Vertical/Horizontal. One stays hidden -->
            <p id="menu_vert" style="display: block">MENU</p>
            <p id="menu_hori" style="display: none">MENU</p>
 <script>
 // Menu Horizontal
    $("p#menu_vert").click(function() {
        $("span#menu").css({"display": "flex"});
        $("p#menu_vert").css({"display": "none"});
        $("p#menu_hori").css({"display": "block"});
        $menulayout = 1;
    });
// Menu Vertical
    $("p#menu_hori").click(function() {
        $("span#menu").css({"display": "block"});
        $("p#menu_hori").css({"display": "none"});
        $("p#menu_vert").css({"display": "block"});
        $menulayout = 0;
    });
</script>
<!-- END Menu control -->
            <p>FILTER</p>
        </div>
        <div class="category">            
            <span id="menu" style="display: block">
            <a href="?type=1"><p<?php print ( $category == FREIGHTER )? " id=\"selected\"":""?>>Freighter</p></a>
            <a href="?type=2"><p<?php print ( $category == TANKER )? " id=\"selected\"":""?>>Tanker</p></a>
            <a href="?type=3"><p<?php print ( $category == WARSHIP )? " id=\"selected\"":""?>>Warship</p></a>
            <a href="?type=4"><p<?php print ( $category == ESCORT )? " id=\"selected\"":""?>>Escort</p></a>
            <a href="?type=5"><p<?php print ( $category == TROOPTRANSPORT )? " id=\"selected\"":""?>>Passenger</p></a>
            <a href="?type=6"><p<?php print ( $category == CARRIER )? " id=\"selected\"":""?>>Carrier</p></a>
            <a href="?type=7"><p<?php print ( $category == OTHER )? " id=\"selected\"":""?>>Other</p></a>
            </span>
        </div>
    </div>
</body>
</html>



And a few images of the pages



TODO
- Filtering for TWOS ships by bow, stacks, superstructures
- Disable view of clone ships that use same model
- Enabling view for hidden ships not shown in TWOS recognition manual
- Parsing of config files from data\roster
- Filtering for all ships by stats, dates, country (bow etc was not included in stock game)
- Enable swipe support for smartphones


CHANGES

2021 09 08
- Cleaned up all pictures to have white backgrounds where possible.
- Reduced size of text
- Fixed logical error causing wrongs shipset to show
- Added tonnage to statistics

2021 09 09
- New gui and slider scripts (old is accessible at https://sh5soan.000webhostapp.com/soan/index_old.php )

fitzcarraldo 09-07-21 06:50 PM

Very nice! Good job!

Many thanks for the work. :Kaleun_Wink:

Fitzcarraldo :Kaleun_Salute:

kapuhy 09-08-21 02:51 AM

Cool idea :up: thanks, I'll use it on my next playthorugh.

What would be even better is to make SOAN app like this. Not just for convenience purposes while targeting, but also because disabling SOAN in Options Editor cuts down TWOS loading time by 90%.

Kedishen 09-08-21 06:51 AM

Quote:

Originally Posted by fitzcarraldo (Post 2767205)
Very nice! Good job!

Many thanks for the work. :Kaleun_Wink:

Fitzcarraldo :Kaleun_Salute:

Hoping it will come in use.

Quote:

Originally Posted by kapuhy (Post 2767237)
Cool idea :up: thanks, I'll use it on my next playthorugh.

What would be even better is to make SOAN app like this. Not just for convenience purposes while targeting, but also because disabling SOAN in Options Editor cuts down TWOS loading time by 90%.

You mean a SOAN app for mobile or for PC? It would certainly take me a lot more time than the few hours I spent on this. But its possible.

Hopfully you have success with using it. If you find any issues or have suggestions, please do post it here.

U-190 09-13-21 12:23 PM

Good job! Thx! :up:


All times are GMT -5. The time now is 11:54 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.